Class CertificateUtils


  • public final class CertificateUtils
    extends Object
    Author:
    Hakan Altindag
    • Method Detail

      • generateAlias

        public static <T extends CertificateString generateAlias​(T certificate)
      • write

        public static <T extends Certificate> void write​(Path destination,
                                                         T certificate)
      • loadCertificate

        public static List<Certificate> loadCertificate​(String... certificatePaths)
        Loads certificates from the classpath and maps it into a list of Certificate.
        Supported input format: PEM, P7B and DER
      • loadCertificate

        public static List<Certificate> loadCertificate​(Path... certificatePaths)
        Loads certificates from the filesystem and maps it into a list of Certificate.
        Supported input format: PEM, P7B and DER
      • loadCertificate

        public static List<Certificate> loadCertificate​(InputStream... certificateStreams)
        Loads certificates from multiple InputStreams and maps it into a list of Certificate.
        Supported input format: PEM, P7B and DER
      • parsePemCertificate

        public static List<Certificate> parsePemCertificate​(String certificateContent)
        Parses PEM formatted certificates containing a header as -----BEGIN CERTIFICATE----- and footer as -----END CERTIFICATE----- or header as -----BEGIN PKCS7----- and footer as -----END PKCS7----- with a base64 encoded data between the header and footer.
      • parseP7bCertificate

        public static List<Certificate> parseP7bCertificate​(String certificateContent)
        Parses P7B formatted certificates containing a header as -----BEGIN PKCS7----- and footer as -----END PKCS7----- with a base64 encoded data between the header and footer.
      • parseDerCertificate

        public static List<Certificate> parseDerCertificate​(InputStream certificateStream)
        PKIX/RFC 5280 states that duplicate extensions are not allowed. See section 4.2 of it. A certificate which contains a duplicate extension is not parseable. Instead of throwing an exception, it will be ignored.
      • getSystemTrustedCertificates

        public static List<X509Certificate> getSystemTrustedCertificates()
      • getCertificatesFromExternalSourceAsPem

        public static List<String> getCertificatesFromExternalSourceAsPem​(String url)
      • getCertificatesFromExternalSourceAsPem

        public static List<String> getCertificatesFromExternalSourceAsPem​(Proxy proxy,
                                                                          String url)
      • getCertificatesFromExternalSourcesAsPem

        public static Map<String,​List<String>> getCertificatesFromExternalSourcesAsPem​(String... urls)
      • getCertificatesFromExternalSourcesAsPem

        public static Map<String,​List<String>> getCertificatesFromExternalSourcesAsPem​(Proxy proxy,
                                                                                             String... urls)
      • getCertificatesFromExternalSourcesAsPem

        public static Map<String,​List<String>> getCertificatesFromExternalSourcesAsPem​(List<String> urls)