Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Add server-side certificate on Windows  (Read 2516 times)

0 Members and 1 Guest are viewing this topic.

kovacsa

    Topic Starter


    Rookie

    • Experience: Beginner
    • OS: Unknown
    Add server-side certificate on Windows
    « on: February 11, 2019, 07:32:08 AM »
    I imported a p12 certificate file to system on Windows 7, on which a Tomcat webapp is running. I try to retrieve certificate with following code:

    Code: [Select]
    private KSPrivateKeyEntry getKSPrivateKeyEntry(final String alias, ProtectionParameter passwordProtection) {
      KeyStore keyStore = getKeyStore();
      try {
        if (keyStore.isKeyEntry(alias)) {
          final PrivateKeyEntry entry = (PrivateKeyEntry) keyStore.getEntry(alias, passwordProtection);
          return new KSPrivateKeyEntry(alias, entry);
        }
      } catch (GeneralSecurityException e) {
        throw new DSSException("Unable to retrieve key for alias '" + alias + "'", e);
      }
      return null;
    }

    Certificate not present in output and I am not sure, how to use alias for a certificate in a proper way.