@Test @DisplayName("url is empty when a certificate has no distribution points") void crlUrlIsEmptyWhenCertificateHasNoDistributionPoints() throws Exception { X509Certificate certificate = (X509Certificate)cf.generateCertificate(CertificationRevocationListImpl.class.getResourceAsStream("/wrong-signature-cert.cer")); List<String> urls = CertificationRevocationListImpl.getCrlDistributionPoints(certificate); Assertions.assertTrue(urls.isEmpty()); }
public static List<String> getCrlDistributionPoints(X509Certificate certificate) { List<String> urls = new ArrayList<>(); try { if (certificate == null || certificate.getNonCriticalExtensionOIDs() == null || !certificate.getNonCriticalExtensionOIDs().contains(Extension.cRLDistributionPoints.getId())) { return urls; } CRLDistPoint distPoint = CRLDistPoint.getInstance(JcaX509ExtensionUtils.parseExtensionValue(certificate.getExtensionValue(Extension.cRLDistributionPoints.getId()))); for ( DistributionPoint dp : distPoint.getDistributionPoints() ) { DistributionPointName distributionPoint = dp.getDistributionPoint(); if (distributionPoint != null && distributionPoint.getType() == DistributionPointName.FULL_NAME) { for ( GeneralName genName : ((GeneralNames)distributionPoint.getName()).getNames() ) { if (genName.getTagNo() == GeneralName.uniformResourceIdentifier) { urls.add(DERIA5String.getInstance(genName.getName()).getString()); } } } } return urls; } catch (IOException e) { log.error("Could not read CRL Distribution Points from certificate with distinguished name: {} ", certificate.getSubjectDN().toString(), e); } return urls; }
CertificationRevocationListImpl implements CertificationRevocationList { public static List<String> getCrlDistributionPoints(X509Certificate certificate) { List<String> urls = new ArrayList<>(); try { if (certificate == null || certificate.getNonCriticalExtensionOIDs() == null || !certificate.getNonCriticalExtensionOIDs().contains(Extension.cRLDistributionPoints.getId())) { return urls; } CRLDistPoint distPoint = CRLDistPoint.getInstance(JcaX509ExtensionUtils.parseExtensionValue(certificate.getExtensionValue(Extension.cRLDistributionPoints.getId()))); for ( DistributionPoint dp : distPoint.getDistributionPoints() ) { DistributionPointName distributionPoint = dp.getDistributionPoint(); if (distributionPoint != null && distributionPoint.getType() == DistributionPointName.FULL_NAME) { for ( GeneralName genName : ((GeneralNames)distributionPoint.getName()).getNames() ) { if (genName.getTagNo() == GeneralName.uniformResourceIdentifier) { urls.add(DERIA5String.getInstance(genName.getName()).getString()); } } } } return urls; } catch (IOException e) { log.error("Could not read CRL Distribution Points from certificate with distinguished name: {} ", certificate.getSubjectDN().toString(), e); } return urls; } }
CertificationRevocationListImpl implements CertificationRevocationList { public static List<String> getCrlDistributionPoints(X509Certificate certificate) { List<String> urls = new ArrayList<>(); try { if (certificate == null || certificate.getNonCriticalExtensionOIDs() == null || !certificate.getNonCriticalExtensionOIDs().contains(Extension.cRLDistributionPoints.getId())) { return urls; } CRLDistPoint distPoint = CRLDistPoint.getInstance(JcaX509ExtensionUtils.parseExtensionValue(certificate.getExtensionValue(Extension.cRLDistributionPoints.getId()))); for ( DistributionPoint dp : distPoint.getDistributionPoints() ) { DistributionPointName distributionPoint = dp.getDistributionPoint(); if (distributionPoint != null && distributionPoint.getType() == DistributionPointName.FULL_NAME) { for ( GeneralName genName : ((GeneralNames)distributionPoint.getName()).getNames() ) { if (genName.getTagNo() == GeneralName.uniformResourceIdentifier) { urls.add(DERIA5String.getInstance(genName.getName()).getString()); } } } } return urls; } catch (IOException e) { log.error("Could not read CRL Distribution Points from certificate with distinguished name: {} ", certificate.getSubjectDN().toString(), e); } return urls; } private  CertificationRevocationListImpl(Set<X509Certificate> masterList,
                                          X509Certificate cscaRootCertificate,
                                          CrlFetcher crlFetcher); }
CertificationRevocationListImpl implements CertificationRevocationList { public static List<String> getCrlDistributionPoints(X509Certificate certificate) { List<String> urls = new ArrayList<>(); try { if (certificate == null || certificate.getNonCriticalExtensionOIDs() == null || !certificate.getNonCriticalExtensionOIDs().contains(Extension.cRLDistributionPoints.getId())) { return urls; } CRLDistPoint distPoint = CRLDistPoint.getInstance(JcaX509ExtensionUtils.parseExtensionValue(certificate.getExtensionValue(Extension.cRLDistributionPoints.getId()))); for ( DistributionPoint dp : distPoint.getDistributionPoints() ) { DistributionPointName distributionPoint = dp.getDistributionPoint(); if (distributionPoint != null && distributionPoint.getType() == DistributionPointName.FULL_NAME) { for ( GeneralName genName : ((GeneralNames)distributionPoint.getName()).getNames() ) { if (genName.getTagNo() == GeneralName.uniformResourceIdentifier) { urls.add(DERIA5String.getInstance(genName.getName()).getString()); } } } } return urls; } catch (IOException e) { log.error("Could not read CRL Distribution Points from certificate with distinguished name: {} ", certificate.getSubjectDN().toString(), e); } return urls; } private  CertificationRevocationListImpl(Set<X509Certificate> masterList,
                                          X509Certificate cscaRootCertificate,
                                          CrlFetcher crlFetcher); static synchronized void initialize(Set<X509Certificate> masterList); static synchronized CertificationRevocationListImpl getInstance(); static List<String> getCrlDistributionPoints(X509Certificate certificate); void renewCrls(); @Override X509CRL getX509CRL(String url); boolean isOnCRL(X509Certificate x509CertificateToCheck); static void reset(); }
CertificationRevocationListImpl implements CertificationRevocationList { public static List<String> getCrlDistributionPoints(X509Certificate certificate) { List<String> urls = new ArrayList<>(); try { if (certificate == null || certificate.getNonCriticalExtensionOIDs() == null || !certificate.getNonCriticalExtensionOIDs().contains(Extension.cRLDistributionPoints.getId())) { return urls; } CRLDistPoint distPoint = CRLDistPoint.getInstance(JcaX509ExtensionUtils.parseExtensionValue(certificate.getExtensionValue(Extension.cRLDistributionPoints.getId()))); for ( DistributionPoint dp : distPoint.getDistributionPoints() ) { DistributionPointName distributionPoint = dp.getDistributionPoint(); if (distributionPoint != null && distributionPoint.getType() == DistributionPointName.FULL_NAME) { for ( GeneralName genName : ((GeneralNames)distributionPoint.getName()).getNames() ) { if (genName.getTagNo() == GeneralName.uniformResourceIdentifier) { urls.add(DERIA5String.getInstance(genName.getName()).getString()); } } } } return urls; } catch (IOException e) { log.error("Could not read CRL Distribution Points from certificate with distinguished name: {} ", certificate.getSubjectDN().toString(), e); } return urls; } private  CertificationRevocationListImpl(Set<X509Certificate> masterList,
                                          X509Certificate cscaRootCertificate,
                                          CrlFetcher crlFetcher); static synchronized void initialize(Set<X509Certificate> masterList); static synchronized CertificationRevocationListImpl getInstance(); static List<String> getCrlDistributionPoints(X509Certificate certificate); void renewCrls(); @Override X509CRL getX509CRL(String url); boolean isOnCRL(X509Certificate x509CertificateToCheck); static void reset();  }