Uploaded image for project: 'OpenAM'
  1. OpenAM
  2. OPENAM-5660

NPE when the keyalias does not exist or does not contain a certificate

    Details

    • Support Ticket IDs:

      Description

      when the keyalias does not exist or does not contain a certificate, the certificate can't be found and therefore, the getCertificate return null:

      
      X509Certificate cert = (X509Certificate) ks.getCertificate(keyAlias);
      
      
      Javadoc of getCertificate:
           * @return the certificate, or null if the given alias does not exist or
           * does not contain a certificate.
      
      

      The null condition should be tested before trying to access the "cert" instance.

      Before:

                  X509Certificate cert = (X509Certificate) ks.getCertificate(keyAlias);
                  pkey = cert.getPublicKey();
      

      After:

                  X509Certificate cert = (X509Certificate) ks.getCertificate(keyAlias);
                  if (cert == null) {
                      logger.error("the given alias '" + keyAlias + "' does not exist or does not contain a certificate.");
                      return null;
                  }
                  pkey = cert.getPublicKey();
      

        Attachments

          Issue Links

            Activity

              People

              • Assignee:
                quentin.castel Quentin CASTEL [X] (Inactive)
                Reporter:
                quentin.castel Quentin CASTEL [X] (Inactive)
              • Votes:
                1 Vote for this issue
                Watchers:
                4 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: