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

    https://github.com/apache/spark/pull/1980#discussion_r17569959
  
    --- Diff: core/src/main/scala/org/apache/spark/ui/JettyUtils.scala ---
    @@ -207,6 +210,48 @@ private[spark] object JettyUtils extends Logging {
       private def attachPrefix(basePath: String, relativePath: String): String 
= {
         if (basePath == "") relativePath else (basePath + 
relativePath).stripSuffix("/")
       }
    +
    +  private def getConnector(port: Int, conf: SparkConf): Connector = {
    +    val https = getHttpPolicy(conf)
    +    if (https) {
    +      buildSslSelectChannelConnector(port, conf)
    +    } else {
    +      conf.set("spark.http.policy", "http")
    +      val connector = new SelectChannelConnector
    +      connector.setPort(port)
    +      connector
    +    }
    +  }
    +
    +  private def buildSslSelectChannelConnector(port: Int, conf: SparkConf): 
Connector =
    +  {
    +    val connector = new SslSelectChannelConnector
    +    connector.setPort(port)
    +
    +    val context = connector.getSslContextFactory
    +    val needAuth = conf.getBoolean("spark.client.https.need-auth", false)
    +
    +    context.setNeedClientAuth(needAuth)
    +    
context.setKeyManagerPassword(conf.get("spark.ssl.server.keystore.keypassword", 
"123456"))
    +    context.setKeyStorePath(conf.get("spark.ssl.server.keystore.location"))
    +    
context.setKeyStorePassword(conf.get("spark.ssl.server.keystore.password", 
"123456"))
    +    context.setKeyStoreType(conf.get("spark.ssl.server.keystore.type", 
"jks"))
    +
    +    if (needAuth && conf.contains("spark.ssl.server.truststore.location")) 
{
    +      
context.setTrustStore(conf.get("spark.ssl.server.truststore.location"))
    +      
context.setTrustStorePassword(conf.get("spark.ssl.server.truststore.password"))
    +      
context.setTrustStoreType(conf.get("spark.ssl.server.truststore.type", "jks"))
    +    }
    +    connector
    +  }
    +
    +  def getHttpPolicy(conf: SparkConf): Boolean = {
    --- End diff --
    
    This is a confusing name, since this function returns a boolean but sounds 
like it will return a "http policy".  `isHttpsEnabled` would be a better name, 
although I'm not sure that we need this:
    
    We should just be able to do
    
    ```
    val https = conf.get("spark.http.policy", "") == "https"
    ```
    
    instead.


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org
For additional commands, e-mail: reviews-h...@spark.apache.org

Reply via email to