Sets the {@code sslProtocol} and {@code trustManager} to use.

@throws NullPointerException if {@code sslProtocol} or {@code trustManager} are null
502968
public ConnectionOptions withSslProtocol(String sslProtocol, TrustManager trustManager)
      throws NoSuchAlgorithmException, KeyManagementException {
    factory.useSslProtocol(Assert.notNull(sslProtocol, "sslProtocol"),
        Assert.notNull(trustManager, "trustManager"));
    return this;
  }
1060659
private void applySslSettings() {
        try {
            TrustManager[] trustManagers = null;
            HostnameVerifier hostnameVerifier = null;
            if (!verifyingSsl) {
                TrustManager trustAll = new X509TrustManager() {
                    @Override
                    public void checkClientTrusted(X509Certificate[] chain, String authType) throws CertificateException {}
                    @Override
                    public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException {}
                    @Override
                    public X509Certificate[] getAcceptedIssuers() { return null; }
                };
                SSLContext sslContext = SSLContext.getInstance("TLS");
                trustManagers = new TrustManager[]{ trustAll };
                hostnameVerifier = new HostnameVerifier() {
                    @Override
                    public boolean verify(String hostname, SSLSession session) { return true; }
                };
            } else if (sslCaCert != null) {
                char[] password = null; // Any password will work.
                CertificateFactory certificateFactory = CertificateFactory.getInstance("X.509");
                Collection<? extends Certificate> certificates = certificateFactory.generateCertificates(sslCaCert);
                if (certificates.isEmpty()) {
                    throw new IllegalArgumentException("expected non-empty set of trusted certificates");
                }
                KeyStore caKeyStore = newEmptyKeyStore(password);
                int index = 0;
                for (Certificate certificate : certificates) {
                    String certificateAlias = "ca" + Integer.toString(index++);
                    caKeyStore.setCertificateEntry(certificateAlias, certificate);
                }
                TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
                trustManagerFactory.init(caKeyStore);
                trustManagers = trustManagerFactory.getTrustManagers();
            }

            if (keyManagers != null || trustManagers != null) {
                SSLContext sslContext = SSLContext.getInstance("TLS");
                sslContext.init(keyManagers, trustManagers, new SecureRandom());
                httpClient.setSslSocketFactory(sslContext.getSocketFactory());
            } else {
                httpClient.setSslSocketFactory(null);
            }
            httpClient.setHostnameVerifier(hostnameVerifier);
        } catch (GeneralSecurityException e) {
            throw new RuntimeException(e);
        }
    }
868495
private void initializeContextManager(Map<String, Object> configProps) throws WIMException {

        iContextManager = new ContextManager();

        /*
         * Set SSL configuration
         */
        iContextManager.setSSLAlias((String) configProps.get("sslRef"));
        iContextManager.setSSLEnabled((Boolean) configProps.get(CONFIG_PROP_SSL_ENABLED));

        /*
         * Set the primary server.
         */
        iContextManager.setPrimaryServer((String) configProps.get(CONFIG_PROP_HOST), (Integer) configProps.get(CONFIG_PROP_PORT));

        /*
         * Set fail-over servers and fail-over behavior.
         */
        for (Map<String, Object> serverConfig : Nester.nest(FAILOVER_SERVERS, configProps)) {
            List<Map<String, Object>> servers = Nester.nest(SERVER2, serverConfig);
            for (Map<String, Object> server : servers) {
                iContextManager.addFailoverServer((String) server.get(CONFIG_PROP_HOST), (Integer) server.get(CONFIG_PROP_PORT));
            }
        }
        iContextManager.setWriteToSecondary(Boolean.getBoolean((String) configProps.get(CONFIG_PROP_ALLOW_WRITE_TO_SECONDARY_SERVERS)));
        iContextManager.setReturnToPrimary((Boolean) configProps.get(CONFIG_PROP_RETURN_TO_PRIMARY_SERVER));
        iContextManager.setQueryInterval((Integer) configProps.get(CONFIG_PROP_PRIMARY_SERVER_QUERY_TIME_INTERVAL) * 60);

        /*
         * Set the simple authentication credentials.
         */
        iContextManager.setSimpleCredentials((String) configProps.get(CONFIG_PROP_BIND_DN), (SerializableProtectedString) configProps.get(CONFIG_PROP_BIND_PASSWORD));

        /*
         * Set the connection timeout.
         */
        iContextManager.setConnectTimeout((Long) configProps.get(CONFIG_PROP_CONNECT_TIMEOUT));

        /*
         * Set the connection timeout.
         */
        iContextManager.setReadTimeout((Long) configProps.get(CONFIG_PROP_READ_TIMEOUT));

        /*
         * Determine referral handling behavior. Initially the attribute was spelled missing an 'r' so
         * for backwards compatibility, support customers who might still be using it. The "referal"
         * attribute has no default so unless it is set we won't use it.
         */
        String referal = (String) configProps.get(CONFIG_PROP_REFERAL);
        String referral = (String) configProps.get(CONFIG_PROP_REFERRAL);
        referral = referal != null ? referal : referral;
        iContextManager.setReferral(referral.toLowerCase());

        /*
         * Set binary attribute names.
         */
        iContextManager.setBinaryAttributeNames(getBinaryAttributes());

        /*
         * Configure the context pool.
         */
        boolean enableContextPool = true;

        List<Map<String, Object>> poolConfigs = Nester.nest(CONFIG_CONTEXT_POOL, configProps);

        Map<String, Object> poolConfig = null;
        if (!poolConfigs.isEmpty()) {
            poolConfig = poolConfigs.get(0);
        }

        /*
         * Enable the context pool if the context pool is enabled and the
         * stand-alone LDAP property reuseConnection has not been set to false.
         */
        boolean reuseConn = (Boolean) configProps.get(CONFIG_REUSE_CONNECTION);
        if (tc.isDebugEnabled()) {
            Tr.debug(tc, "Set reuseConnection as [" + reuseConn + "]");
        }
        if (poolConfig != null) {
            enableContextPool = (Boolean) poolConfig.get(CONFIG_PROP_ENABLED);
        }
        if (!reuseConn) {
            enableContextPool = false;
        }

        Integer initPoolSize = null;
        Integer maxPoolSize = null;
        Integer prefPoolSize = null;
        Long poolTimeOut = null;
        Long poolWaitTime = null;

        if (enableContextPool) {
            if (poolConfig != null) {
                if (poolConfig.get(CONFIG_PROP_INIT_POOL_SIZE) != null) {
                    initPoolSize = (Integer) poolConfig.get(CONFIG_PROP_INIT_POOL_SIZE);
                }
                if (poolConfig.get(CONFIG_PROP_MAX_POOL_SIZE) != null) {
                    maxPoolSize = (Integer) poolConfig.get(CONFIG_PROP_MAX_POOL_SIZE);
                }
                if (poolConfig.get(CONFIG_PROP_PREF_POOL_SIZE) != null) {
                    prefPoolSize = (Integer) poolConfig.get(CONFIG_PROP_PREF_POOL_SIZE);
                }

                if (poolConfig.get(CONFIG_PROP_POOL_TIME_OUT) != null) {
                    poolTimeOut = (Long) poolConfig.get(CONFIG_PROP_POOL_TIME_OUT);

                    /**
                     * The metatype is set to long for this property and all
                     * values will be passed as milliseconds.
                     * A value of 0 means no timeout, leave at 0
                     * Between 0 and 1000ms, round up to 1s
                     * Otherwise round to nearest second
                     */
                    if (poolTimeOut > 0 && poolTimeOut <= 1000) {
                        poolTimeOut = 1l; // override to 1 second
                    } else {
                        poolTimeOut = roundToSeconds(poolTimeOut);
                    }
                }
                if (poolConfig.get(CONFIG_PROP_POOL_WAIT_TIME) != null) {
                    poolWaitTime = (Long) poolConfig.get((CONFIG_PROP_POOL_WAIT_TIME));
                }
            }
        }

        /*
         * Set the configuration on the ContextManager.
         */
        iContextManager.setContextPool(enableContextPool, initPoolSize, prefPoolSize, maxPoolSize, poolTimeOut, poolWaitTime);

        /*
         * Initialize the ContextManager.
         *
         * Only need to check for missing password as the configuration for LDAP would catch a missing
         * primary server. The password is optional and only required when the bind DN is configured.
         */
        InitializeResult result = iContextManager.initialize();
        if (result == InitializeResult.MISSING_PASSWORD) {
            String msg = Tr.formatMessage(tc, WIMMessageKey.MISSING_INI_PROPERTY, WIMMessageHelper.generateMsgParms(CONFIG_PROP_BIND_PASSWORD));
            throw new MissingInitPropertyException(WIMMessageKey.MISSING_INI_PROPERTY, msg);
        }
    }
1021815
public void setSslScanResult(com.google.api.ads.admanager.axis.v201811.SslScanResult sslScanResult) {
        this.sslScanResult = sslScanResult;
    }
279973
public void setSAMLProviderList(java.util.Collection<SAMLProviderListEntry> sAMLProviderList) {
        if (sAMLProviderList == null) {
            this.sAMLProviderList = null;
            return;
        }

        this.sAMLProviderList = new com.amazonaws.internal.SdkInternalList<SAMLProviderListEntry>(sAMLProviderList);
    }
967589
private void setInitializeAtStartup(Boolean flag) {
        this.initializeAtStartup = flag;
        setProperty(Constants.SSLPROP_KEY_STORE_INITIALIZE_AT_STARTUP, flag.toString());
    }
1151686
public synchronized void setDefaultSSLContext() throws Exception {

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.entry(tc, "setDefaultSSLContext");

        if (FrameworkState.isStopping()) {
            return;
        }

        SSLConfig defaultSSLConfig = getDefaultSSLConfig();

        if (defaultSSLConfig != null)
            JSSEProviderFactory.getInstance(null).setServerDefaultSSLContext(defaultSSLConfig);
        else {
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled())
                Tr.debug(tc, "There is no default SSLConfig.");
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.exit(tc, "setDefaultSSLContext");

    }
1263984
@Override
    public boolean setInitParameter(String name, String value) throws IllegalStateException, IllegalArgumentException {
        if (name == null) {
            logger.logp(Level.SEVERE, CLASS_NAME, "setInitParameter", servlet40NLS.getString("name.is.null"));
            throw new java.lang.NullPointerException(servlet40NLS.getString("name.is.null"));
        }

        return super.setInitParameter(name, value);
    }
450913
public B tls(KeyManagerFactory keyManagerFactory,
                 Consumer<SslContextBuilder> tlsCustomizer) throws SSLException {
        requireNonNull(keyManagerFactory, "keyManagerFactory");
        requireNonNull(tlsCustomizer, "tlsCustomizer");

        tls(buildSslContext(() -> SslContextBuilder.forServer(keyManagerFactory), tlsCustomizer));
        return self();
    }
1320147
public synchronized void addSSLPropertiesFromTrustStore(WSKeyStore wsts, SSLConfig sslprops) {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.entry(tc, "addSSLPropertiesFromTrustStore");

        for (Enumeration<?> e = wsts.propertyNames(); e.hasMoreElements();) {
            String property = (String) e.nextElement();
            String value = wsts.getProperty(property);
            String trustManagerProperty = null;

            if (property.startsWith(Constants.SSLPROP_KEY_STORE)) {
                if (property.length() == Constants.SSLPROP_KEY_STORE.length()) {
                    trustManagerProperty = Constants.SSLPROP_TRUST_STORE;
                } else {
                    trustManagerProperty = Constants.SSLPROP_TRUST_STORE + property.substring(Constants.SSLPROP_KEY_STORE.length());
                }
            }

            if (trustManagerProperty != null && value != null)
                sslprops.setProperty(trustManagerProperty, value);
        }
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            Tr.exit(tc, "addSSLPropertiesFromTrustStore");
    }
172067
protected void init()
    {
        // "support for SSL"
        String handlerPkgs = System.getProperty("java.protocol.handler.pkgs");
        if ((handlerPkgs != null) && !(handlerPkgs.isEmpty())) {
            handlerPkgs = handlerPkgs + "|com.sun.net.ssl.internal.www.protocol";
        } else {
        	handlerPkgs = "com.sun.net.ssl.internal.www.protocol";
        }
        System.setProperty("java.protocol.handler.pkgs", handlerPkgs);

        java.security.Security
                .addProvider(new com.sun.net.ssl.internal.ssl.Provider());

        // Create custom EditorKit if needed
        if (swingBoxEditorKit == null) {
            swingBoxEditorKit = new SwingBoxEditorKit();
        }

        setEditable(false);
        setContentType("text/html");

        activateTooltip(true);

        Caret caret = getCaret();
        if (caret instanceof DefaultCaret)
        	((DefaultCaret) caret).setUpdatePolicy(DefaultCaret.NEVER_UPDATE);
    }
695350
public void setTrustStore(String trustStore, String trustPass, String trustManagerType, String trustStoreType) 
    {
        if((trustStore == null) || (trustPass == null))
        {
            this.trustStore =  System.getProperty("javax.net.ssl.trustStore");
            this.trustPass =  System.getProperty("javax.net.ssl.trustStorePassword");
        }
        else
        {
            this.trustStore = trustStore;
            this.trustPass = trustPass;
        }
 
        if (trustManagerType != null) {
            this.trustManagerType = trustManagerType;
        }
        if (trustStoreType != null) {
            this.trustStoreType = trustStoreType;
        }
        isTrustStoreSet = (trustStore != null) && (trustPass != null);
    }
439005
public void setSecureLevel(short secureLevel) throws ClassException {
	// Security
	if (secureLevel == SECURE_CFSSL_BASIC) {
	    env.put("java.naming.security.protocol", "ssl");
	    env.put("java.naming.ldap.factory.socket", "javax.net.ssl.SSLSocketFactory");
	    ClassUtil.loadClass("com.sun.net.ssl.internal.ssl.Provider");

	    Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());

	}
	else if (secureLevel == SECURE_CFSSL_CLIENT_AUTH) {
	    env.put("java.naming.security.protocol", "ssl");
	    env.put("java.naming.security.authentication", "EXTERNAL");
	}
	else {
	    env.put("java.naming.security.authentication", "simple");
	    env.remove("java.naming.security.protocol");
	    env.remove("java.naming.ldap.factory.socket");
	}
    }
754344
@Beta
  public static SSLContext trustAllSSLContext() throws GeneralSecurityException {
    TrustManager[] trustAllCerts =
        new TrustManager[] {
          new X509TrustManager() {

            public void checkClientTrusted(X509Certificate[] chain, String authType)
                throws CertificateException {}

            public void checkServerTrusted(X509Certificate[] chain, String authType)
                throws CertificateException {}

            public X509Certificate[] getAcceptedIssuers() {
              return null;
            }
          }
        };
    SSLContext context = getTlsSslContext();
    context.init(null, trustAllCerts, null);
    return context;
  }
917015
public static void configureProtocolHandler() {
        final String pkgs = System.getProperty("java.protocol.handler.pkgs");
        String newValue = "org.mapfish.print.url";
        if (pkgs != null && !pkgs.contains(newValue)) {
            newValue = newValue + "|" + pkgs;
        } else if (pkgs != null) {
            newValue = pkgs;
        }
        System.setProperty("java.protocol.handler.pkgs", newValue);
    }
185993
public static void configureTls(ServerBuilder sb, Ssl ssl) {
        configureTls(sb, ssl, null, null);
    }
790114
@Nullable
	private static SSLContext createRestSSLContext(Configuration config, RestSSLContextConfigMode configMode) throws Exception {
		checkNotNull(config, "config");

		if (!isRestSSLEnabled(config)) {
			return null;
		}

		KeyManager[] keyManagers = null;
		if (configMode == RestSSLContextConfigMode.SERVER || configMode == RestSSLContextConfigMode.MUTUAL) {
			String keystoreFilePath = getAndCheckOption(
				config, SecurityOptions.SSL_REST_KEYSTORE, SecurityOptions.SSL_KEYSTORE);

			String keystorePassword = getAndCheckOption(
				config, SecurityOptions.SSL_REST_KEYSTORE_PASSWORD, SecurityOptions.SSL_KEYSTORE_PASSWORD);

			String certPassword = getAndCheckOption(
				config, SecurityOptions.SSL_REST_KEY_PASSWORD, SecurityOptions.SSL_KEY_PASSWORD);

			KeyStore keyStore = KeyStore.getInstance(KeyStore.getDefaultType());
			try (InputStream keyStoreFile = Files.newInputStream(new File(keystoreFilePath).toPath())) {
				keyStore.load(keyStoreFile, keystorePassword.toCharArray());
			}

			KeyManagerFactory kmf = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
			kmf.init(keyStore, certPassword.toCharArray());

			keyManagers = kmf.getKeyManagers();
		}

		TrustManager[] trustManagers = null;
		if (configMode == RestSSLContextConfigMode.CLIENT || configMode == RestSSLContextConfigMode.MUTUAL) {
			String trustStoreFilePath = getAndCheckOption(
				config, SecurityOptions.SSL_REST_TRUSTSTORE, SecurityOptions.SSL_TRUSTSTORE);

			String trustStorePassword = getAndCheckOption(
				config, SecurityOptions.SSL_REST_TRUSTSTORE_PASSWORD, SecurityOptions.SSL_TRUSTSTORE_PASSWORD);

			KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
			try (InputStream trustStoreFile = Files.newInputStream(new File(trustStoreFilePath).toPath())) {
				trustStore.load(trustStoreFile, trustStorePassword.toCharArray());
			}

			TrustManagerFactory tmf = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());
			tmf.init(trustStore);

			trustManagers = tmf.getTrustManagers();
		}

		String sslProtocolVersion = config.getString(SecurityOptions.SSL_PROTOCOL);
		SSLContext sslContext = SSLContext.getInstance(sslProtocolVersion);
		sslContext.init(keyManagers, trustManagers, null);

		return sslContext;
	}