diff --git a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/CertificateDAOImpl.java b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/CertificateDAOImpl.java index 27a15314..1b80ef9e 100644 --- a/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/CertificateDAOImpl.java +++ b/src/main/java/ch/ethz/seb/sebserver/webservice/servicelayer/dao/impl/CertificateDAOImpl.java @@ -216,23 +216,21 @@ public class CertificateDAOImpl implements CertificateDAO { final boolean[] keyUsage = cert.getKeyUsage(); final EnumSet result = EnumSet.noneOf(CertificateType.class); - // digitalSignature - if (keyUsage[0]) { - result.add(CertificateType.DIGITAL_SIGNATURE); - } + if (keyUsage != null) { + // digitalSignature + if (keyUsage[0]) { + result.add(CertificateType.DIGITAL_SIGNATURE); + } - // dataEncipherment - if (keyUsage[2] || keyUsage[3]) { - result.add(CertificateType.DATA_ENCIPHERMENT); - } + // dataEncipherment + if (keyUsage[2] || keyUsage[3]) { + result.add(CertificateType.DATA_ENCIPHERMENT); + } - // keyCertSign - if (keyUsage[5]) { - result.add(CertificateType.KEY_CERT_SIGN); - } - - if (result.isEmpty()) { - result.add(CertificateType.UNKNOWN); + // keyCertSign + if (keyUsage[5]) { + result.add(CertificateType.KEY_CERT_SIGN); + } } final String alias = certificates.keyStore.engineGetCertificateAlias(cert); @@ -240,6 +238,10 @@ public class CertificateDAOImpl implements CertificateDAO { result.add(CertificateType.DATA_ENCIPHERMENT_PRIVATE_KEY); } + if (result.isEmpty()) { + result.add(CertificateType.UNKNOWN); + } + return result; }