Class CertificateAmendment


  • public final class CertificateAmendment
    extends java.lang.Object
    Class to add missing root certificates to the list of trusted certificates for TLS connections. The added certificates are deemed trustworthy by the main web browsers and operating systems, but not included in some distributions of Java. The certificates are added in-memory at each start, nothing is written to disk.
    Since:
    9995
    • Method Detail

      • addMissingCertificates

        public static void addMissingCertificates()
                                           throws java.io.IOException,
                                                  java.security.GeneralSecurityException
        Add missing root certificates to the list of trusted certificates for TLS connections.
        Throws:
        java.io.IOException - if an I/O error occurs
        java.security.GeneralSecurityException - if a security error occurs
      • checkAndAddCertificate

        private static boolean checkAndAddCertificate​(java.security.MessageDigest md,
                                                      java.security.cert.X509Certificate cert,
                                                      CertificateAmendment.CertAmend certAmend,
                                                      java.security.KeyStore keyStore)
                                               throws java.security.cert.CertificateEncodingException,
                                                      java.security.KeyStoreException,
                                                      java.security.InvalidAlgorithmParameterException
        Throws:
        java.security.cert.CertificateEncodingException
        java.security.KeyStoreException
        java.security.InvalidAlgorithmParameterException
      • certificateIsMissing

        private static boolean certificateIsMissing​(java.security.KeyStore keyStore,
                                                    java.security.cert.X509Certificate crt)
                                             throws java.security.KeyStoreException,
                                                    java.security.InvalidAlgorithmParameterException
        Check if the certificate is missing and needs to be added to the keystore.
        Parameters:
        keyStore - the keystore
        crt - the certificate
        Returns:
        true, if the certificate is not contained in the keystore
        Throws:
        java.security.InvalidAlgorithmParameterException - if the keystore does not contain at least one trusted certificate entry
        java.security.KeyStoreException - if the keystore has not been initialized