|
18 | 18 | package org.apache.spark |
19 | 19 |
|
20 | 20 | import java.io.{File, FileInputStream} |
| 21 | +import java.security.{KeyStore, NoSuchAlgorithmException} |
| 22 | + |
| 23 | +import javax.net.ssl.{KeyManager, KeyManagerFactory, SSLContext, TrustManager, TrustManagerFactory} |
21 | 24 |
|
22 | 25 | import com.typesafe.config.{Config, ConfigFactory, ConfigValueFactory} |
23 | 26 | import org.eclipse.jetty.util.ssl.SslContextFactory |
24 | 27 |
|
25 | | -import javax.net.ssl.{KeyManager, KeyManagerFactory, SSLContext, TrustManager, TrustManagerFactory} |
26 | | -import java.security.{KeyStore, NoSuchAlgorithmException} |
27 | | - |
28 | 28 | /** |
29 | 29 | * SSLOptions class is a common container for SSL configuration options. It offers methods to |
30 | 30 | * generate specific objects to configure SSL for different communication protocols. |
@@ -111,22 +111,22 @@ private[spark] case class SSLOptions( |
111 | 111 | * are supported by the current Java security provider for this protocol. |
112 | 112 | */ |
113 | 113 | private val supportedAlgorithms: Set[String] = { |
114 | | - var context: Option[SSLContext] = Some(SSLContext.getDefault) |
| 114 | + var context: SSLContext = null |
115 | 115 | try { |
116 | | - context = Some(SSLContext.getInstance(protocol.orNull)) |
| 116 | + context = SSLContext.getInstance(protocol.orNull) |
117 | 117 | /* The set of supported algorithms does not depend upon the keys, trust, or |
118 | 118 | rng, although they will influence which algorithms are eventually used. */ |
119 | | - context.foreach(_.init(null, null, null)) |
| 119 | + context.init(null, null, null) |
120 | 120 | } catch { |
121 | 121 | case npe: NullPointerException => |
122 | 122 | logDebug("No SSL protocol specified") |
| 123 | + context = SSLContext.getDefault |
123 | 124 | case nsa: NoSuchAlgorithmException => |
124 | 125 | logDebug(s"No support for requested SSL protocol ${protocol.get}") |
| 126 | + context = SSLContext.getDefault |
125 | 127 | } |
126 | 128 |
|
127 | | - val providerAlgorithms = context |
128 | | - .map(_.getServerSocketFactory.getSupportedCipherSuites.toSet) |
129 | | - .getOrElse(Set.empty) |
| 129 | + val providerAlgorithms = context.getServerSocketFactory.getSupportedCipherSuites.toSet |
130 | 130 |
|
131 | 131 | // Log which algorithms we are discarding |
132 | 132 | (enabledAlgorithms &~ providerAlgorithms).foreach { cipher => |
|
0 commit comments