Github user vanzin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/3571#discussion_r23036138
  
    --- Diff: core/src/main/scala/org/apache/spark/SecurityManager.scala ---
    @@ -196,6 +201,43 @@ private[spark] class SecurityManager(sparkConf: 
SparkConf) extends Logging with
         )
       }
     
    +  private[spark] val sslOptions = SSLOptions.parse(sparkConf, "spark.ssl")
    +
    +  private[spark] val (sslSocketFactory, hostnameVerifier) = if 
(sslOptions.enabled) {
    +    val trustStoreManagers =
    +      for (trustStore <- sslOptions.trustStore) yield {
    +        val ks = KeyStore.getInstance(KeyStore.getDefaultType)
    +        ks.load(Files.asByteSource(sslOptions.trustStore.get).openStream(),
    +          sslOptions.trustStorePassword.get.toCharArray)
    +
    +        val tmf = 
TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm)
    +        tmf.init(ks)
    +        tmf.getTrustManagers
    +      }
    +
    +    lazy val credulousTrustStoreManagers = Array({
    +      logWarning("Using 'accept-all' trust manager for SSL connections.")
    +      new X509TrustManager {
    +        override def getAcceptedIssuers: Array[X509Certificate] = null
    +
    +        override def checkClientTrusted(x509Certificates: 
Array[X509Certificate], s: String) {}
    +
    +        override def checkServerTrusted(x509Certificates: 
Array[X509Certificate], s: String) {}
    +      }: TrustManager
    +    })
    +
    +    val sslContext = 
SSLContext.getInstance(sslOptions.protocol.getOrElse("Default"))
    +    sslContext.init(null, trustStoreManagers getOrElse 
credulousTrustStoreManagers, null)
    --- End diff --
    
    nit: missing `.` for the method calls (i.e. "don't use postfix ops")


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to