docs: @Override
      public X509Certificate getX509CertificateFromKeyStore(String keyStoreName) throws KeyStoreException, CertificateException {
          try {
              KeyStore ks = ksMgr.getJavaKeyStore(keyStoreName);
              if (ks == null) {
                  throw new KeyStoreException("The keystore [" + keyStoreName + "] is not present in the configuration");
              } else {
                  String keyAlias = null;
                  Enumeration<String> aliases = ks.aliases();
                  if (aliases != null) {
                      while (aliases.hasMoreElements()) {
                          String alias = aliases.nextElement();
                          if (ks.isKeyEntry(alias)) {
                              if (keyAlias != null)
                                  return null;
                              else
                                  keyAlias = alias;
                          }
                      }
                  }
                  if (keyAlias != null) {
                      WSKeyStore wsKS = ksMgr.getKeyStore(keyStoreName);
                      if (wsKS == null) {
                          throw new CertificateException("The WSKeyStore [" + keyStoreName + "] is not present in the configuration");
                      }
  
                      // get the private key
                      Certificate cert = ks.getCertificate(keyAlias);
                      if (cert instanceof X509Certificate) {
                          return (X509Certificate) cert;
                      } else {
                          throw new CertificateException("The alias [" + keyAlias + "] is not an instance of X509Certificate");
                      }
                  }
              }
          } catch (CertificateException e) {
              throw e;
          } catch (KeyStoreException e) {
              throw e;
          } catch (SSLException e) {
              throw new KeyStoreException(e.getLocalizedMessage(), e);
          } catch (Exception e) {
              throw new KeyStoreException("Unexpected error while loading the private key for alias from keystore: " + keyStoreName, e);
          }
          return null;
      }