X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=certServicePostProcessor%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Foom%2Fcertservice%2Fpostprocessor%2Fmerger%2Fmodel%2FPemTruststore.java;fp=certServicePostProcessor%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Foom%2Fcertservice%2Fpostprocessor%2Fmerger%2Fmodel%2FPemTruststore.java;h=8e360523b20139e10489e486954e73d59e1159ed;hb=12594ee752b79605c61ff019fdeb471bf7ca4058;hp=642721cc7d86e3fa94f10ac7e3dc43e2b96fdad8;hpb=a239249475c128781d6c3d68de22c00f67203eaf;p=oom%2Fplatform%2Fcert-service.git diff --git a/certServicePostProcessor/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/PemTruststore.java b/certServicePostProcessor/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/PemTruststore.java index 642721cc..8e360523 100644 --- a/certServicePostProcessor/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/PemTruststore.java +++ b/certServicePostProcessor/src/main/java/org/onap/oom/certservice/postprocessor/merger/model/PemTruststore.java @@ -29,6 +29,7 @@ import java.io.IOException; import java.io.StringWriter; import java.security.Security; import java.security.cert.Certificate; +import java.security.cert.CertificateException; import java.security.cert.CertificateFactory; import java.util.ArrayList; import java.util.List; @@ -89,8 +90,13 @@ public class PemTruststore extends Truststore { } boolean isFileWithoutPemCertificate() throws TruststoreDataOperationException { - List certificateList = extractCertificatesFromFile(); - return certificateList.isEmpty(); + try { + List certificateList = extractCertificatesFromFile(); + return certificateList.isEmpty(); + } catch (TruststoreDataOperationException e) { + LOGGER.error("Cannot extract certificates from file: {}", storeFile.getPath()); + } + return true; } String transformToStringInPemFormat(List certificates) throws TruststoreDataOperationException { @@ -112,7 +118,12 @@ public class PemTruststore extends Truststore { Security.addProvider(new BouncyCastleProvider()); CertificateFactory certFactory = CertificateFactory.getInstance(X_509_CERTIFICATE, BOUNCY_CASTLE_PROVIDER); return new ArrayList<>(certFactory.generateCertificates(inputStream)); - } catch (Exception e) { + } + catch (CertificateException e) { + LOGGER.error("Cannot read certificates from file: {}", storeFile.getPath()); + throw new TruststoreDataOperationException(e); + } + catch (Exception e) { LOGGER.error("Cannot read certificates from file: {}", storeFile.getPath()); throw new TruststoreDataOperationException(e); }