Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8362455

Test test/jdk/sun/security/ssl/SignatureScheme/MD5NotAllowedInTLS13CertificateSignature.java correction

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 25
    • security-libs

      It is observed that method (customCertificateBuilder) in test class test/jdk/sun/security/ssl/SignatureScheme/MD5NotAllowedInTLS13CertificateSignature.java needs a correction.

      While creating a certificate with validity params of notBefore and notAfter, instead the certificate is created notAfter both the times. However the test is passing in main because internally if "notBefore" is NULL, the variable is assigned to default value whereas in LTS versions the same is not available (which means "notBefore is NULL which throws NPE exception). The same is corrected while doing backport however the code is still available in main.

      Main line code :

       private static CertificateBuilder customCertificateBuilder(
                  String subjectName, PublicKey publicKey, PublicKey caKey)
                  throws CertificateException, IOException {
              SecureRandom random = new SecureRandom();

              CertificateBuilder builder = new CertificateBuilder()
                      .setSubjectName(subjectName)
                      .setPublicKey(publicKey)
                      .setNotAfter(
                              Date.from(Instant.now().minus(1, ChronoUnit.HOURS)))
                      .setNotAfter(Date.from(Instant.now().plus(1, ChronoUnit.HOURS)))
                      .setSerialNumber(
                              BigInteger.valueOf(random.nextLong(1000000) + 1))
                      .addSubjectKeyIdExt(publicKey)
                      .addAuthorityKeyIdExt(caKey);
              builder.addKeyUsageExt(
                      new boolean[]{true, true, true, true, true, true});

              return builder;
          }

      Observe the below lines of code
       .setNotAfter(Date.from(Instant.now().minus(1, ChronoUnit.HOURS)))
       .setNotAfter(Date.from(Instant.now().plus(1, ChronoUnit.HOURS)))

            ksreenath Konanki Sreenath
            ksreenath Konanki Sreenath
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: