Class CertificateTest


  • public class CertificateTest
    extends java.lang.Object
    • Constructor Detail

      • CertificateTest

        public CertificateTest()
    • Method Detail

      • beforeClass

        public static void beforeClass()
      • testCertRSA

        public void testCertRSA()
                         throws java.security.cert.CertificateException,
                                java.io.IOException
        Checks that the encoded form of the certificate of every configured RSA key size is the DER resource it was loaded from.
        Throws:
        java.io.IOException
        java.security.cert.CertificateException
      • testCertPem

        public void testCertPem()
                         throws java.security.cert.CertificateException,
                                java.io.IOException
        Checks that the encoded form of a certificate read in PEM is the PEM resource it was loaded from.

        The expectation is derived from the resource rather than written out, so that regenerating the test material does not require editing this test. Line separators are removed on both sides because the file is stored in git and its line endings depend on the checkout.

        Throws:
        java.io.IOException
        java.security.cert.CertificateException
      • testCertEC

        public void testCertEC()
                        throws java.security.cert.CertificateException,
                               java.io.IOException
        Checks that the encoded form of the certificate of every configured Elliptic Curve is the DER resource it was loaded from.
        Throws:
        java.io.IOException
        java.security.cert.CertificateException
      • checkValidityDoesNotThrowExceptionForValidCertificate

        public void checkValidityDoesNotThrowExceptionForValidCertificate()
                                                                   throws java.security.cert.CertificateException,
                                                                          java.io.IOException
        Uses a known certificate valid for a long time, uses current time to check the certificate validity.
        The test succeeds if there is no exception.
        Throws:
        java.security.cert.CertificateException - for any certificate related error
        java.io.IOException - for any file related error
      • checkValidityThrowsExceptionForCertificateNotYetValid

        public void checkValidityThrowsExceptionForCertificateNotYetValid()
                                                                   throws java.security.cert.CertificateException,
                                                                          java.io.IOException
        Uses a known valid in the future certificate, uses current time to check the certificate validity.
        The test expects a CertificateNotYetValidException exception.
        Throws:
        java.security.cert.CertificateException - for any certificate related error
        java.io.IOException - for any file related error
      • checkValidityThrowsExceptionForExpiredCertificate

        public void checkValidityThrowsExceptionForExpiredCertificate()
                                                               throws java.security.cert.CertificateException,
                                                                      java.io.IOException
        Uses a known old certificate, uses current time to check the certificate validity.
        The test expects a CertificateExpiredException exception.
        Throws:
        java.security.cert.CertificateException - for any certificate related error
        java.io.IOException - for any file related error
      • verifyCertificateWithValidKey_EC

        public void verifyCertificateWithValidKey_EC()
                                              throws java.lang.Exception
        Verifies the signature of a certificate using the public part of the key that was used to sign it. The test succeed if the signature is valid. PK: EC, every configured curve
        Throws:
        java.lang.Exception
      • verifyCertificateWithValidKey_RSA

        public void verifyCertificateWithValidKey_RSA()
                                               throws java.lang.Exception
        Verifies the signature of a certificate using the public part of the key that was used to sign it. The test succeed if the signature is valid PK: RSA, every configured key size
        Throws:
        java.lang.Exception
      • verifyCertificateWithInvalidKey_EC

        public void verifyCertificateWithInvalidKey_EC()
                                                throws java.lang.Exception
        Verifies the signature of a certificate using an unrelated public key. The test succeed if the signature is invalid. PK: EC, every configured curve
        Throws:
        java.lang.Exception
      • verifyCertificateWithInvalidKey_RSA

        public void verifyCertificateWithInvalidKey_RSA()
                                                 throws java.lang.Exception
        Verifies the signature of a certificate using an unrelated public key. The test succeed if the signature is invalid. PK: RSA, every configured key size
        Throws:
        java.lang.Exception