OPENDJ-2399: Start server fails if the jvm used does not contains an
elliptic curve certificate provider.
* Removed EC certificate for all connectors.
* Add support for multiple certificate nicknames in dsconfig.
* Align HTTPS SSL configuration on the LDAPS one during setup.
| | |
| | | ds-cfg-use-ssl: false |
| | | ds-cfg-ssl-client-auth-policy: optional |
| | | ds-cfg-ssl-cert-nickname: server-cert |
| | | ds-cfg-ssl-cert-nickname: server-cert-ec |
| | | |
| | | dn: cn=LDAPS Connection Handler,cn=Connection Handlers,cn=config |
| | | objectClass: top |
| | |
| | | ds-cfg-use-ssl: true |
| | | ds-cfg-ssl-client-auth-policy: optional |
| | | ds-cfg-ssl-cert-nickname: server-cert |
| | | ds-cfg-ssl-cert-nickname: server-cert-ec |
| | | ds-cfg-key-manager-provider: cn=JKS,cn=Key Manager Providers,cn=config |
| | | ds-cfg-trust-manager-provider: cn=JKS,cn=Trust Manager Providers,cn=config |
| | | |
| | |
| | | ds-cfg-use-ssl: false |
| | | ds-cfg-ssl-client-auth-policy: optional |
| | | ds-cfg-ssl-cert-nickname: server-cert |
| | | ds-cfg-ssl-cert-nickname: server-cert-ec |
| | | ds-cfg-config-file: config/http-config.json |
| | | ds-cfg-authentication-required: true |
| | | |
| | |
| | | ds-cfg-use-ssl: false |
| | | ds-cfg-listen-port: 1689 |
| | | ds-cfg-ssl-cert-nickname: server-cert |
| | | ds-cfg-ssl-cert-nickname: server-cert-ec |
| | | |
| | | dn: cn=Entry Caches,cn=config |
| | | objectClass: top |
| | |
| | | ds-cfg-listen-address: 0.0.0.0 |
| | | ds-cfg-listen-port: 4444 |
| | | ds-cfg-ssl-cert-nickname: admin-cert |
| | | ds-cfg-ssl-cert-nickname: admin-cert-ec |
| | | ds-cfg-key-manager-provider: cn=Administration,cn=Key Manager Providers,cn=config |
| | | ds-cfg-trust-manager-provider: cn=Administration,cn=Trust Manager Providers,cn=config |
| | | |
| | |
| | | */ |
| | | package org.opends.quicksetup; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.Collection; |
| | | import java.util.Set; |
| | | import java.util.TreeSet; |
| | | |
| | | /** |
| | | * Class used to describe the Security Options specified by the user. |
| | |
| | | private CertificateType certificateType; |
| | | private String keyStorePath; |
| | | private String keyStorePassword; |
| | | private String aliasToUse; |
| | | private Set<String> aliasesToUse = new TreeSet<>(); |
| | | |
| | | private SecurityOptions() |
| | | { |
| | |
| | | public static SecurityOptions createSelfSignedCertificateOptions( |
| | | boolean enableSSL, boolean enableStartTLS, int sslPort) |
| | | { |
| | | return createSelfSignedCertificateOptions(enableSSL, enableStartTLS, sslPort, SELF_SIGNED_CERT_ALIAS); |
| | | return createSelfSignedCertificateOptions(enableSSL, enableStartTLS, sslPort, |
| | | Arrays.asList(SELF_SIGNED_CERT_ALIAS)); |
| | | } |
| | | |
| | | /** |
| | |
| | | * whether Start TLS is enabled or not. |
| | | * @param sslPort |
| | | * the value of the LDAPS port. |
| | | * @param aliasToUse |
| | | * the alias of the certificate in the key store to be used. |
| | | * @param aliasesToUse |
| | | * the aliases of the certificates in the key store to be used. |
| | | * @return a new instance of a SecurityOptions using a self-signed |
| | | * certificate. |
| | | */ |
| | | public static SecurityOptions createSelfSignedCertificateOptions(boolean enableSSL, boolean enableStartTLS, |
| | | int sslPort, String aliasToUse) |
| | | int sslPort, Collection<String> aliasesToUse) |
| | | { |
| | | return createOptionsForCertificatType( |
| | | CertificateType.SELF_SIGNED_CERTIFICATE, null, null, enableSSL, enableStartTLS, sslPort, aliasToUse); |
| | | CertificateType.SELF_SIGNED_CERTIFICATE, null, null, enableSSL, enableStartTLS, sslPort, aliasesToUse); |
| | | } |
| | | |
| | | /** |
| | |
| | | * whether Start TLS is enabled or not. |
| | | * @param sslPort |
| | | * the value of the LDAPS port. |
| | | * @param aliasToUse |
| | | * the alias of the certificate in the key store to be used. |
| | | * @param aliasesToUse |
| | | * the aliases of the certificates in the key store to be used. |
| | | * @return a new instance of a SecurityOptions using a Java Key Store. |
| | | */ |
| | | public static SecurityOptions createJKSCertificateOptions(String keystorePath, String keystorePwd, boolean enableSSL, |
| | | boolean enableStartTLS, int sslPort, String aliasToUse) |
| | | boolean enableStartTLS, int sslPort, Collection<String> aliasesToUse) |
| | | { |
| | | return createOptionsForCertificatType( |
| | | CertificateType.JKS, keystorePath, keystorePwd, enableSSL, enableStartTLS, sslPort, aliasToUse); |
| | | CertificateType.JKS, keystorePath, keystorePwd, enableSSL, enableStartTLS, sslPort, aliasesToUse); |
| | | } |
| | | |
| | | /** |
| | |
| | | * whether Start TLS is enabled or not. |
| | | * @param sslPort |
| | | * the value of the LDAPS port. |
| | | * @param aliasToUse |
| | | * the alias of the certificate in the keystore to be used. |
| | | * @param aliasesToUse |
| | | * the aliases of the certificates in the keystore to be used. |
| | | * @return a new instance of a SecurityOptions using a JCE Key Store. |
| | | */ |
| | | public static SecurityOptions createJCEKSCertificateOptions(String keystorePath, String keystorePwd, |
| | | boolean enableSSL, boolean enableStartTLS, int sslPort, String aliasToUse) |
| | | boolean enableSSL, boolean enableStartTLS, int sslPort, Collection<String> aliasesToUse) |
| | | { |
| | | return createOptionsForCertificatType( |
| | | CertificateType.JCEKS, keystorePath, keystorePwd, enableSSL, enableStartTLS, sslPort, aliasToUse); |
| | | CertificateType.JCEKS, keystorePath, keystorePwd, enableSSL, enableStartTLS, sslPort, aliasesToUse); |
| | | } |
| | | |
| | | |
| | |
| | | * whether Start TLS is enabled or not. |
| | | * @param sslPort |
| | | * the value of the LDAPS port. |
| | | * @param aliasToUse |
| | | * the alias of the certificate in the keystore to be used. |
| | | * @param aliasesToUse |
| | | * the aliases of the certificates in the keystore to be used. |
| | | * @return a new instance of a SecurityOptions using a PKCS#11 Key Store. |
| | | */ |
| | | public static SecurityOptions createPKCS11CertificateOptions(String keystorePwd, boolean enableSSL, |
| | | boolean enableStartTLS, int sslPort, String aliasToUse) |
| | | boolean enableStartTLS, int sslPort, Collection<String> aliasesToUse) |
| | | { |
| | | return createOptionsForCertificatType( |
| | | CertificateType.PKCS11, null, keystorePwd, enableSSL, enableStartTLS, sslPort, aliasToUse); |
| | | CertificateType.PKCS11, null, keystorePwd, enableSSL, enableStartTLS, sslPort, aliasesToUse); |
| | | } |
| | | |
| | | /** |
| | |
| | | * whether Start TLS is enabled or not. |
| | | * @param sslPort |
| | | * the value of the LDAPS port. |
| | | * @param aliasToUse |
| | | * the alias of the certificate in the keystore to be used. |
| | | * @param aliasesToUse |
| | | * the aliases of the certificates in the keystore to be used. |
| | | * @return a new instance of a SecurityOptions using a PKCS#12 Key Store. |
| | | */ |
| | | public static SecurityOptions createPKCS12CertificateOptions( String keystorePath, String keystorePwd, |
| | | boolean enableSSL, boolean enableStartTLS, int sslPort, String aliasToUse) |
| | | boolean enableSSL, boolean enableStartTLS, int sslPort, Collection<String> aliasesToUse) |
| | | { |
| | | return createOptionsForCertificatType( |
| | | CertificateType.PKCS12, keystorePath, keystorePwd, enableSSL, enableStartTLS, sslPort, aliasToUse); |
| | | CertificateType.PKCS12, keystorePath, keystorePwd, enableSSL, enableStartTLS, sslPort, aliasesToUse); |
| | | } |
| | | |
| | | /** |
| | |
| | | * Whether Start TLS is enabled or not. |
| | | * @param sslPort |
| | | * The value of the LDAPS port. |
| | | * @param aliasToUse |
| | | * The alias of the certificate in the keystore to be used. |
| | | * @param aliasesToUse |
| | | * The aliases of the certificates in the keystore to be used. |
| | | * @return a new instance of a SecurityOptions. |
| | | */ |
| | | public static SecurityOptions createOptionsForCertificatType(CertificateType certType, String keystorePath, |
| | | String keystorePwd, boolean enableSSL, boolean enableStartTLS, int sslPort, String aliasToUse) |
| | | String keystorePwd, boolean enableSSL, boolean enableStartTLS, int sslPort, Collection<String> aliasesToUse) |
| | | { |
| | | if (certType == CertificateType.NO_CERTIFICATE) |
| | | { |
| | |
| | | ops.setKeyStorePassword(keystorePwd); |
| | | } |
| | | ops.setCertificateType(certType); |
| | | updateCertificateOptions(ops, enableSSL, enableStartTLS, sslPort, aliasToUse); |
| | | updateCertificateOptions(ops, enableSSL, enableStartTLS, sslPort, aliasesToUse); |
| | | return ops; |
| | | } |
| | | |
| | |
| | | * @param aliasToUse the name of the alias to be used. |
| | | */ |
| | | private static void updateCertificateOptions(SecurityOptions ops, |
| | | boolean enableSSL, boolean enableStartTLS, int sslPort, String aliasToUse) |
| | | boolean enableSSL, boolean enableStartTLS, int sslPort, Collection<String> aliasesToUse) |
| | | { |
| | | if (!enableSSL && !enableStartTLS) |
| | | { |
| | |
| | | ops.setEnableSSL(enableSSL); |
| | | ops.setEnableStartTLS(enableStartTLS); |
| | | ops.setSslPort(sslPort); |
| | | ops.setAliasToUse(aliasToUse); |
| | | ops.setAliasToUse(aliasesToUse); |
| | | } |
| | | |
| | | /** |
| | |
| | | * Returns the alias of the certificate in the key store to be used. |
| | | * @return the alias of the certificate in the key store to be used. |
| | | */ |
| | | public String getAliasToUse() |
| | | public Set<String> getAliasesToUse() |
| | | { |
| | | return aliasToUse; |
| | | return aliasesToUse; |
| | | } |
| | | |
| | | /** |
| | | * Sets the certificate alias name. |
| | | * @param aliasToUse the certificate alias name. |
| | | * Sets the certificates aliases name. |
| | | * @param aliasesToUse the certificates aliases name. |
| | | */ |
| | | void setAliasToUse(String aliasToUse) |
| | | void setAliasToUse(Collection<String> aliasesToUse) |
| | | { |
| | | this.aliasToUse = aliasToUse; |
| | | this.aliasesToUse.clear(); |
| | | this.aliasesToUse.addAll(aliasesToUse); |
| | | } |
| | | |
| | | } |
| | |
| | | argList.add("--adminConnectorPort"); |
| | | argList.add(String.valueOf(getUserData().getAdminConnectorPort())); |
| | | |
| | | SecurityOptions sec = getUserData().getSecurityOptions(); |
| | | final SecurityOptions sec = getUserData().getSecurityOptions(); |
| | | configureCertificate(sec); |
| | | // TODO: even if the user does not configure SSL maybe we should choose |
| | | // a secure port that is not being used and that we can actually use. |
| | | if (sec.getEnableSSL()) |
| | |
| | | invokeLongOperation(thread); |
| | | notifyListeners(getFormattedDoneWithLineBreak()); |
| | | checkAbort(); |
| | | configureCertificate(sec); |
| | | } |
| | | |
| | | private void configureCertificate(SecurityOptions sec) throws ApplicationException |
| | |
| | | String pwd = getSelfSignedCertificatePwd(); |
| | | final CertificateManager certManager = |
| | | new CertificateManager(getSelfSignedKeystorePath(), CertificateManager.KEY_STORE_TYPE_JKS, pwd); |
| | | for (String alias : SELF_SIGNED_CERT_ALIASES) |
| | | for (String alias : sec.getAliasesToUse()) |
| | | { |
| | | final KeyType keyType = KeyType.getTypeOrDefault(alias); |
| | | certManager.generateSelfSignedCertificate(keyType, alias, getSelfSignedCertificateSubjectDN(keyType), |
| | |
| | | final String trustStoreType, final SecurityOptions sec) throws Exception |
| | | { |
| | | final String keystorePassword = sec.getKeystorePassword(); |
| | | final String keyStoreAlias = sec.getAliasToUse(); |
| | | |
| | | CertificateManager certManager = new CertificateManager(keyStorePath, keyStoreType, keystorePassword); |
| | | for (String keyStoreAlias : sec.getAliasesToUse()) |
| | | { |
| | | SetupUtils.exportCertificate(certManager, keyStoreAlias, getTemporaryCertificatePath()); |
| | | configureTrustStore(trustStoreType, keyStoreAlias, keystorePassword); |
| | | } |
| | | } |
| | | |
| | | private void configureTrustStore(final String type, final String keyStoreAlias, final String password) |
| | | throws Exception |
| | |
| | | |
| | | private void addCertificateArguments(SecurityOptions sec, List<String> argList) |
| | | { |
| | | final String aliasInKeyStore = sec.getAliasToUse(); |
| | | final Collection<String> aliasInKeyStore = sec.getAliasesToUse(); |
| | | |
| | | switch (sec.getCertificateType()) |
| | | { |
| | |
| | | } |
| | | } |
| | | |
| | | private void addCertificateArguments(List<String> argList, SecurityOptions sec, String aliasInKeyStore, |
| | | String keyStoreDN, String trustStoreDN) |
| | | private static void addCertificateArguments(List<String> argList, SecurityOptions sec, |
| | | Collection<String> aliasesInKeyStore, String keyStoreDN, String trustStoreDN) |
| | | { |
| | | argList.add("-k"); |
| | | argList.add(keyStoreDN); |
| | |
| | | argList.add("-m"); |
| | | argList.add(sec.getKeystorePath()); |
| | | } |
| | | if (aliasInKeyStore != null) |
| | | for(String alias : aliasesInKeyStore) |
| | | { |
| | | argList.add("-a"); |
| | | argList.add(aliasInKeyStore); |
| | | argList.add(alias); |
| | | } |
| | | } |
| | | |
| | |
| | | try { |
| | | for (String alias : SELF_SIGNED_CERT_ALIASES) |
| | | { |
| | | if (cm.aliasInUse(alias)) |
| | | { |
| | | cm.removeCertificate(alias); |
| | | } |
| | | } |
| | | } catch (KeyStoreException e) { |
| | | logger.info(LocalizableMessage.raw("Error deleting self signed certification", e)); |
| | | } |
| | |
| | | import java.io.File; |
| | | import java.security.KeyStoreException; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | |
| | | import javax.swing.Box; |
| | | import javax.swing.ButtonGroup; |
| | |
| | | ops = SecurityOptions.createJKSCertificateOptions( |
| | | tfKeystorePath.getText(), |
| | | String.valueOf(tfKeystorePwd.getPassword()), enableSSL, |
| | | enableStartTLS, sslPort, selectedAlias); |
| | | enableStartTLS, sslPort, Arrays.asList(selectedAlias)); |
| | | } |
| | | else if (rbJCEKS.isSelected()) |
| | | { |
| | | ops = SecurityOptions.createJCEKSCertificateOptions( |
| | | tfKeystorePath.getText(), |
| | | String.valueOf(tfKeystorePwd.getPassword()), enableSSL, |
| | | enableStartTLS, sslPort, selectedAlias); |
| | | enableStartTLS, sslPort, Arrays.asList(selectedAlias)); |
| | | } |
| | | else if (rbPKCS11.isSelected()) |
| | | { |
| | | ops = SecurityOptions.createPKCS11CertificateOptions( |
| | | String.valueOf(tfKeystorePwd.getPassword()), enableSSL, |
| | | enableStartTLS, sslPort, selectedAlias); |
| | | enableStartTLS, sslPort, Arrays.asList(selectedAlias)); |
| | | } |
| | | else if (rbPKCS12.isSelected()) |
| | | { |
| | | ops = SecurityOptions.createPKCS12CertificateOptions( |
| | | tfKeystorePath.getText(), |
| | | String.valueOf(tfKeystorePwd.getPassword()), enableSSL, |
| | | enableStartTLS, sslPort, selectedAlias); |
| | | enableStartTLS, sslPort, Arrays.asList(selectedAlias)); |
| | | } |
| | | else |
| | | { |
| | |
| | | case JKS: |
| | | cmdLine.add("--useJavaKeystore"); |
| | | cmdLine.add(userData.getSecurityOptions().getKeystorePath()); |
| | | if (userData.getSecurityOptions().getKeystorePassword() != null) |
| | | { |
| | | cmdLine.add("--keyStorePassword"); |
| | | cmdLine.add(OBFUSCATED_VALUE); |
| | | } |
| | | |
| | | if (userData.getSecurityOptions().getAliasToUse() != null) |
| | | { |
| | | cmdLine.add("--certNickname"); |
| | | cmdLine.add(userData.getSecurityOptions().getAliasToUse()); |
| | | } |
| | | addKeyStoreAndCert(userData.getSecurityOptions(), cmdLine); |
| | | break; |
| | | |
| | | case JCEKS: |
| | | cmdLine.add("--useJCEKS"); |
| | | cmdLine.add(userData.getSecurityOptions().getKeystorePath()); |
| | | |
| | | if (userData.getSecurityOptions().getKeystorePassword() != null) |
| | | { |
| | | cmdLine.add("--keyStorePassword"); |
| | | cmdLine.add(OBFUSCATED_VALUE); |
| | | } |
| | | |
| | | if (userData.getSecurityOptions().getAliasToUse() != null) |
| | | { |
| | | cmdLine.add("--certNickname"); |
| | | cmdLine.add(userData.getSecurityOptions().getAliasToUse()); |
| | | } |
| | | addKeyStoreAndCert(userData.getSecurityOptions(), cmdLine); |
| | | break; |
| | | |
| | | case PKCS12: |
| | | cmdLine.add("--usePkcs12keyStore"); |
| | | cmdLine.add(userData.getSecurityOptions().getKeystorePath()); |
| | | |
| | | if (userData.getSecurityOptions().getKeystorePassword() != null) |
| | | { |
| | | cmdLine.add("--keyStorePassword"); |
| | | cmdLine.add(OBFUSCATED_VALUE); |
| | | } |
| | | |
| | | if (userData.getSecurityOptions().getAliasToUse() != null) |
| | | { |
| | | cmdLine.add("--certNickname"); |
| | | cmdLine.add(userData.getSecurityOptions().getAliasToUse()); |
| | | } |
| | | addKeyStoreAndCert(userData.getSecurityOptions(), cmdLine); |
| | | break; |
| | | |
| | | case PKCS11: |
| | | cmdLine.add("--usePkcs11Keystore"); |
| | | |
| | | if (userData.getSecurityOptions().getKeystorePassword() != null) |
| | | { |
| | | cmdLine.add("--keyStorePassword"); |
| | | cmdLine.add(OBFUSCATED_VALUE); |
| | | } |
| | | |
| | | if (userData.getSecurityOptions().getAliasToUse() != null) |
| | | { |
| | | cmdLine.add("--certNickname"); |
| | | cmdLine.add(userData.getSecurityOptions().getAliasToUse()); |
| | | } |
| | | addKeyStoreAndCert(userData.getSecurityOptions(), cmdLine); |
| | | break; |
| | | |
| | | default: |
| | |
| | | return cmdLine; |
| | | } |
| | | |
| | | private static void addKeyStoreAndCert(final SecurityOptions securityOptions, final List<String> cmdLine) |
| | | { |
| | | if (securityOptions.getKeystorePassword() != null) |
| | | { |
| | | cmdLine.add("--keyStorePassword"); |
| | | cmdLine.add(OBFUSCATED_VALUE); |
| | | } |
| | | |
| | | for(String alias : securityOptions.getAliasesToUse()) |
| | | { |
| | | cmdLine.add("--certNickname"); |
| | | cmdLine.add(alias); |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Returns the list of equivalent command-lines that must be executed to |
| | | * enable or initialize replication as the setup does. |
| | |
| | | /** The DN of the configuration entry defining the LDAPS connection handler. */ |
| | | private static final String DN_LDAPS_CONNECTION_HANDLER = "cn=LDAPS Connection Handler," + DN_CONNHANDLER_BASE; |
| | | |
| | | /** The DN of the configuration entry defining the HTTP connection handler. */ |
| | | private static final String DN_HTTP_CONNECTION_HANDLER = |
| | | "cn=HTTP Connection Handler,cn=Connection Handlers,cn=config"; |
| | | |
| | | /** The DN of the configuration entry defining the JMX connection handler. */ |
| | | private static final String DN_JMX_CONNECTION_HANDLER = "cn=JMX Connection Handler," + DN_CONNHANDLER_BASE; |
| | | |
| | |
| | | private StringArgument rootPassword; |
| | | private StringArgument keyManagerProviderDN; |
| | | private StringArgument trustManagerProviderDN; |
| | | private StringArgument certNickName; |
| | | private StringArgument certNickNames; |
| | | private StringArgument keyManagerPath; |
| | | private StringArgument serverRoot; |
| | | private StringArgument backendType; |
| | |
| | | null, null, INFO_CONFIGDS_DESCRIPTION_KEYMANAGER_PATH.get()); |
| | | argParser.addArgument(keyManagerPath); |
| | | |
| | | certNickName = new StringArgument( |
| | | certNickNames = new StringArgument( |
| | | "certnickname", 'a', "certNickName", |
| | | false, false, true, INFO_NICKNAME_PLACEHOLDER.get(), |
| | | false, true, true, INFO_NICKNAME_PLACEHOLDER.get(), |
| | | null, null, INFO_CONFIGDS_DESCRIPTION_CERTNICKNAME.get()); |
| | | argParser.addArgument(certNickName); |
| | | argParser.addArgument(certNickNames); |
| | | |
| | | baseDNString = new StringArgument( |
| | | "basedn", OPTION_SHORT_BASEDN, OPTION_LONG_BASEDN, |
| | |
| | | |
| | | putKeyManagerConfigAttribute(enableStartTLS, DN_LDAP_CONNECTION_HANDLER); |
| | | putKeyManagerConfigAttribute(ldapsPort, DN_LDAPS_CONNECTION_HANDLER); |
| | | putKeyManagerConfigAttribute(ldapsPort, DN_HTTP_CONNECTION_HANDLER); |
| | | |
| | | if (keyManagerPath.isPresent()) |
| | | { |
| | |
| | | } |
| | | putTrustManagerAttribute(enableStartTLS, DN_LDAP_CONNECTION_HANDLER); |
| | | putTrustManagerAttribute(ldapsPort, DN_LDAPS_CONNECTION_HANDLER); |
| | | putTrustManagerAttribute(ldapsPort, DN_HTTP_CONNECTION_HANDLER); |
| | | } |
| | | |
| | | if (certNickName.isPresent()) |
| | | if (certNickNames.isPresent()) |
| | | { |
| | | final StringConfigAttribute certNickNameAttr = new StringConfigAttribute( |
| | | final StringConfigAttribute certNickNamesAttr = new StringConfigAttribute( |
| | | ATTR_SSL_CERT_NICKNAME, INFO_LDAP_CONNHANDLER_DESCRIPTION_SSL_CERT_NICKNAME.get(), |
| | | false, false, true, certNickName.getValue()); |
| | | updateCertNicknameEntry(ldapPort, DN_LDAP_CONNECTION_HANDLER, certNickNameAttr); |
| | | updateCertNicknameEntry(ldapsPort, DN_LDAPS_CONNECTION_HANDLER, certNickNameAttr); |
| | | false, true, true, certNickNames.getValues()); |
| | | updateCertNicknameEntry(ldapPort, DN_LDAP_CONNECTION_HANDLER, certNickNamesAttr); |
| | | updateCertNicknameEntry(ldapsPort, DN_LDAPS_CONNECTION_HANDLER, certNickNamesAttr); |
| | | updateCertNicknameEntry(certNickNames, DN_HTTP_CONNECTION_HANDLER, certNickNamesAttr); |
| | | |
| | | final StringConfigAttribute certNickNameJmxAttr = new StringConfigAttribute( |
| | | final StringConfigAttribute certNickNamesJmxAttr = new StringConfigAttribute( |
| | | ATTR_SSL_CERT_NICKNAME, INFO_JMX_CONNHANDLER_DESCRIPTION_SSL_CERT_NICKNAME.get(), |
| | | false, false, true, certNickName.getValue()); |
| | | updateCertNicknameEntry(jmxPort, DN_JMX_CONNECTION_HANDLER, certNickNameJmxAttr); |
| | | false, false, true, certNickNames.getValues()); |
| | | updateCertNicknameEntry(jmxPort, DN_JMX_CONNECTION_HANDLER, certNickNamesJmxAttr); |
| | | } |
| | | else |
| | | { |
| | | // Use the key manager specified for connection handlers |
| | | removeSSLCertNicknameAttribute(DN_LDAP_CONNECTION_HANDLER); |
| | | removeSSLCertNicknameAttribute(DN_LDAPS_CONNECTION_HANDLER); |
| | | removeSSLCertNicknameAttribute(DN_HTTP_CONNECTION_HANDLER); |
| | | removeSSLCertNicknameAttribute(DN_JMX_CONNECTION_HANDLER); |
| | | } |
| | | } |
| | |
| | | import java.io.OutputStream; |
| | | import java.io.PrintStream; |
| | | import java.security.KeyStoreException; |
| | | import java.util.ArrayList; |
| | | import java.util.Arrays; |
| | | import java.util.Collection; |
| | | import java.util.Collections; |
| | |
| | | certType = SecurityOptions.CertificateType.NO_CERTIFICATE; |
| | | } |
| | | |
| | | String certNickname = argParser.certNicknameArg.getValue(); |
| | | Collection<String> certNicknames = argParser.certNicknameArg.getValues(); |
| | | if (pathToCertificat != null) |
| | | { |
| | | checkCertificateInKeystore(certType, pathToCertificat, pwd, certNickname, errorMessages, keystoreAliases); |
| | | if (certNickname == null && !keystoreAliases.isEmpty()) |
| | | checkCertificateInKeystore(certType, pathToCertificat, pwd, certNicknames, errorMessages, keystoreAliases); |
| | | if (certNicknames.isEmpty() && !keystoreAliases.isEmpty()) |
| | | { |
| | | certNickname = keystoreAliases.getFirst(); |
| | | certNicknames = Arrays.asList(keystoreAliases.getFirst()); |
| | | } |
| | | } |
| | | |
| | | final SecurityOptions securityOptions = SecurityOptions.createOptionsForCertificatType( |
| | | certType, pathToCertificat, pwd, enableSSL, enableStartTLS, sslPort, certNickname); |
| | | certType, pathToCertificat, pwd, enableSSL, enableStartTLS, sslPort, certNicknames); |
| | | uData.setSecurityOptions(securityOptions); |
| | | } |
| | | |
| | |
| | | * the path of the key store. |
| | | * @param pwd |
| | | * the password (PIN) to access the key store. |
| | | * @param certNickname |
| | | * the certificate nickname that we are looking for (or null if we |
| | | * @param certNicknames |
| | | * the certificate nicknames that we are looking for (or null if we |
| | | * just one to get the one that is in the key store). |
| | | * @param errorMessages |
| | | * the list that will be updated with the errors encountered. |
| | |
| | | * store. |
| | | */ |
| | | public static void checkCertificateInKeystore(SecurityOptions.CertificateType type, String path, String pwd, |
| | | String certNickname, Collection<LocalizableMessage> errorMessages, Collection<String> nicknameList) |
| | | Collection<String> certNicknames, Collection<LocalizableMessage> errorMessages, Collection<String> nicknameList) |
| | | { |
| | | boolean errorWithPath = false; |
| | | if (type != SecurityOptions.CertificateType.PKCS11) |
| | |
| | | { |
| | | Collections.addAll(nicknameList, aliases); |
| | | final String aliasString = joinAsString(", ", nicknameList); |
| | | if (certNickname != null) |
| | | if (certNicknames.isEmpty() && aliases.length > 1) |
| | | { |
| | | errorMessages.add(ERR_INSTALLDS_MUST_PROVIDE_CERTNICKNAME.get(aliasString)); |
| | | } |
| | | for (String certNickname : certNicknames) |
| | | { |
| | | // Check if the certificate alias is in the list. |
| | | boolean found = false; |
| | |
| | | errorMessages.add(ERR_INSTALLDS_CERTNICKNAME_NOT_FOUND.get(aliasString)); |
| | | } |
| | | } |
| | | else if (aliases.length > 1) |
| | | { |
| | | errorMessages.add(ERR_INSTALLDS_MUST_PROVIDE_CERTNICKNAME.get(aliasString)); |
| | | } |
| | | } |
| | | } |
| | | catch (final KeyStoreException ke) |
| | |
| | | { |
| | | SecurityOptions securityOptions; |
| | | String path; |
| | | String certNickname = argParser.certNicknameArg.getValue(); |
| | | Collection<String> certNicknames = argParser.certNicknameArg.getValues(); |
| | | String pwd = argParser.getKeyStorePassword(); |
| | | if (pwd != null && pwd.length() == 0) |
| | | { |
| | |
| | | { |
| | | errorMessages.clear(); |
| | | keystoreAliases.clear(); |
| | | checkCertificateInKeystore(type, path, pwd, certNickname, |
| | | errorMessages, keystoreAliases); |
| | | checkCertificateInKeystore(type, path, pwd, certNicknames, errorMessages, keystoreAliases); |
| | | if (!errorMessages.isEmpty()) |
| | | { |
| | | // Reset password: this might be a new keystore |
| | |
| | | { |
| | | println(); |
| | | } |
| | | certNickname = promptForCertificateNickname(keystoreAliases); |
| | | certNicknames = promptForCertificateNickname(keystoreAliases); |
| | | } |
| | | errorMessages.clear(); |
| | | keystoreAliases.clear(); |
| | | checkCertificateInKeystore(type, path, pwd, certNickname, errorMessages, |
| | | checkCertificateInKeystore(type, path, pwd, certNicknames, errorMessages, |
| | | keystoreAliases); |
| | | firstTry = false; |
| | | } |
| | | if (certNickname == null && !keystoreAliases.isEmpty()) |
| | | if (certNicknames.isEmpty() && !keystoreAliases.isEmpty()) |
| | | { |
| | | certNickname = keystoreAliases.getFirst(); |
| | | certNicknames = Arrays.asList(keystoreAliases.getFirst()); |
| | | } |
| | | switch (type) |
| | | { |
| | | case JKS: |
| | | securityOptions = SecurityOptions.createJKSCertificateOptions( |
| | | path, pwd, enableSSL, enableStartTLS, ldapsPort, certNickname); |
| | | break; |
| | | return SecurityOptions.createJKSCertificateOptions(path, pwd, enableSSL, enableStartTLS, ldapsPort, |
| | | certNicknames); |
| | | case JCEKS: |
| | | securityOptions = SecurityOptions.createJCEKSCertificateOptions( |
| | | path, pwd, enableSSL, enableStartTLS, ldapsPort, certNickname); |
| | | break; |
| | | return SecurityOptions.createJCEKSCertificateOptions(path, pwd, enableSSL, enableStartTLS, ldapsPort, |
| | | certNicknames); |
| | | case PKCS12: |
| | | securityOptions = SecurityOptions.createPKCS12CertificateOptions( |
| | | path, pwd, enableSSL, enableStartTLS, ldapsPort, certNickname); |
| | | break; |
| | | return SecurityOptions.createPKCS12CertificateOptions(path, pwd, enableSSL, enableStartTLS, ldapsPort, |
| | | certNicknames); |
| | | case PKCS11: |
| | | securityOptions = SecurityOptions.createPKCS11CertificateOptions( |
| | | pwd, enableSSL, enableStartTLS, ldapsPort, certNickname); |
| | | break; |
| | | return SecurityOptions.createPKCS11CertificateOptions(pwd, enableSSL, enableStartTLS, ldapsPort, certNicknames); |
| | | default: |
| | | throw new IllegalStateException( |
| | | "Called createSecurityOptionsPrompting with invalid type: "+type); |
| | | throw new IllegalStateException("Called createSecurityOptionsPrompting with invalid type: " + type); |
| | | } |
| | | return securityOptions; |
| | | } |
| | | |
| | | /** |
| | |
| | | * the list of certificates the user must choose from. |
| | | * @return the chosen certificate nickname. |
| | | */ |
| | | private String promptForCertificateNickname(List<String> nicknames) |
| | | private Collection<String> promptForCertificateNickname(List<String> nicknames) |
| | | { |
| | | String nickname = null; |
| | | while (nickname == null) |
| | | Collection<String> choosenNicknames = new ArrayList<>(); |
| | | while (choosenNicknames.isEmpty()) |
| | | { |
| | | for (final String n : nicknames) |
| | | { |
| | |
| | | { |
| | | if (confirmAction(INFO_INSTALLDS_PROMPT_CERTNICKNAME.get(n), true)) |
| | | { |
| | | nickname = n; |
| | | break; |
| | | choosenNicknames.add(n); |
| | | } |
| | | } |
| | | catch (final ClientException ce) |
| | |
| | | } |
| | | } |
| | | } |
| | | return nickname; |
| | | return choosenNicknames; |
| | | } |
| | | |
| | | /** |
| | |
| | | certNicknameArg = new StringArgument( |
| | | OPTION_LONG_CERT_NICKNAME.toLowerCase(), |
| | | OPTION_SHORT_CERT_NICKNAME, OPTION_LONG_CERT_NICKNAME, |
| | | false, false, true, INFO_NICKNAME_PLACEHOLDER.get(), null, |
| | | false, true, true, INFO_NICKNAME_PLACEHOLDER.get(), null, |
| | | OPTION_LONG_CERT_NICKNAME, |
| | | INFO_INSTALLDS_DESCRIPTION_CERT_NICKNAME.get()); |
| | | addDefaultArgument(certNicknameArg); |
| | |
| | | |
| | | |
| | | import java.security.KeyStoreException; |
| | | import java.security.NoSuchAlgorithmException; |
| | | import java.security.KeyPairGenerator; |
| | | import java.security.KeyStore; |
| | | import java.security.PrivateKey; |
| | | import java.security.cert.Certificate; |
| | |
| | | } |
| | | |
| | | /** |
| | | * Check whether or not, this key type is supported by the current JVM. |
| | | * @return true if this key type is supported, false otherwise. |
| | | */ |
| | | public boolean isSupported() |
| | | { |
| | | try |
| | | { |
| | | return KeyPairGenerator.getInstance(keyAlgorithm.toUpperCase()) != null; |
| | | } |
| | | catch (NoSuchAlgorithmException e) |
| | | { |
| | | return false; |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * Get a KeyType based on the alias name. |
| | | * |
| | | * @param alias |
| | |
| | | return clientAlias; |
| | | } |
| | | } |
| | | logger.info(INFO_MISSING_KEY_TYPE_IN_ALIASES, componentName, aliases.toString(), Arrays.toString(keyType)); |
| | | logger.debug(INFO_MISSING_KEY_TYPE_IN_ALIASES, componentName, aliases.toString(), Arrays.toString(keyType)); |
| | | return null; |
| | | } |
| | | |
| | |
| | | return serverAlias; |
| | | } |
| | | } |
| | | logger.info(INFO_MISSING_KEY_TYPE_IN_ALIASES, componentName, aliases.toString(), Arrays.toString(keyType)); |
| | | logger.debug(INFO_MISSING_KEY_TYPE_IN_ALIASES, componentName, aliases.toString(), Arrays.toString(keyType)); |
| | | return null; |
| | | } |
| | | |