flink-instrumentation/workspace/flink-1.4.1-instrumented/flink-1.4.1/flink-runtime/src/main/java/org/apache/flink/runtime/net/SSLUtils.java
/**
	 * Creates the SSL Context for the client if SSL is configured.
	 *
	 * @param sslConfig
	 *        The application configuration
	 * @return The SSLContext object which can be used by the ssl transport client
	 * 	       Returns null if SSL is disabled
	 * @throws Exception
	 *         Thrown if there is any misconfiguration
	 */
Creates the SSL Context for the client if SSL is configured.
@param sslConfig
The application configuration
@return The SSLContext object which can be used by the ssl transport client
Returns null if SSL is disabled
@throws Exception
Thrown if there is any misconfiguration
Creates the SSL Context for the client if SSL is configured . @param sslConfig The application configuration @return The SSLContext object which can be used by the ssl transport client Returns null if SSL is disabled @throws Exception Thrown if there is any misconfiguration
public static SSLContext createSSLClientContext(Configuration sslConfig) throws Exception {
		Preconditions.checkNotNull(sslConfig);
		SSLContext clientSSLContext = null;
		if (getSSLEnabled(sslConfig)) {
			LOG.debug("Creating client SSL context from configuration");
			String trustStoreFilePath = sslConfig.getString(SecurityOptions.SSL_TRUSTSTORE);
			String trustStorePassword = sslConfig.getString(SecurityOptions.SSL_TRUSTSTORE_PASSWORD);
			String sslProtocolVersion = sslConfig.getString(SecurityOptions.SSL_PROTOCOL);
			Preconditions.checkNotNull(trustStoreFilePath, SecurityOptions.SSL_TRUSTSTORE.key() + " was not configured.");
			Preconditions.checkNotNull(trustStorePassword, SecurityOptions.SSL_TRUSTSTORE_PASSWORD.key() + " was not configured.");
			KeyStore trustStore = KeyStore.getInstance(KeyStore.getDefaultType());
			FileInputStream trustStoreFile = null;
			try {
				trustStoreFile = new FileInputStream(new File(trustStoreFilePath));
				trustStore.load(trustStoreFile, trustStorePassword.toCharArray());
			} finally {
				if (trustStoreFile != null) {
					trustStoreFile.close();
				}
			}
			TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(
				TrustManagerFactory.getDefaultAlgorithm());
			trustManagerFactory.init(trustStore);
			clientSSLContext = SSLContext.getInstance(sslProtocolVersion);
			clientSSLContext.init(null, trustManagerFactory.getTrustManagers(), null);
		}
		return clientSSLContext;
	}
public static SSLContext createSSLClientContext ( Configuration sslConfig ) throws Exception { Preconditions . checkNotNull ( sslConfig ) ; SSLContext clientSSLContext = null ; if ( getSSLEnabled ( sslConfig ) ) { LOG . debug ( "Creating client SSL context from configuration" ) ; String trustStoreFilePath = sslConfig . getString ( SecurityOptions . SSL_TRUSTSTORE ) ; String trustStorePassword = sslConfig . getString ( SecurityOptions . SSL_TRUSTSTORE_PASSWORD ) ; String sslProtocolVersion = sslConfig . getString ( SecurityOptions . SSL_PROTOCOL ) ; Preconditions . checkNotNull ( trustStoreFilePath , SecurityOptions . SSL_TRUSTSTORE . key ( ) + " was not configured." ) ; Preconditions . checkNotNull ( trustStorePassword , SecurityOptions . SSL_TRUSTSTORE_PASSWORD . key ( ) + " was not configured." ) ; KeyStore trustStore = KeyStore . getInstance ( KeyStore . getDefaultType ( ) ) ; FileInputStream trustStoreFile = null ; try { trustStoreFile = new FileInputStream ( new File ( trustStoreFilePath ) ) ; trustStore . load ( trustStoreFile , trustStorePassword . toCharArray ( ) ) ; } finally { if ( trustStoreFile != null ) { trustStoreFile . close ( ) ; } } TrustManagerFactory trustManagerFactory = TrustManagerFactory . getInstance ( TrustManagerFactory . getDefaultAlgorithm ( ) ) ; trustManagerFactory . init ( trustStore ) ; clientSSLContext = SSLContext . getInstance ( sslProtocolVersion ) ; clientSSLContext . init ( null , trustManagerFactory . getTrustManagers ( ) , null ) ; } return clientSSLContext ; }
Creates the SSL Context for the client if SSL is configured.
Creates the SSL Context for the client if SSL is configured .