Use https in spark-java

前端 未结 1 1859
终归单人心
终归单人心 2021-02-05 12:28

How can i use custom SSLContext and custom SSLServerSocketFactory in spark-java framework? I\'ve searched in SparkServerImpl but have no idea how to inject sslfactory, any sugge

1条回答
  •  被撕碎了的回忆
    2021-02-05 13:29

    You can pass directly into Spark the parameters of the keystore, like this:

    Spark.secure(keyStorePath, keyStorePassword, trustStorePath, trustStorePassword);
    

    Those are all strings, and for example, the keystore values could be:

    String keyStorePath = "/home/user/keys/private-key.jks";
    String keyStorePassword = "password";
    

    This way, Spark will have the parameters to create the SslContextFactory inside, as you can see here:

    https://github.com/perwendel/spark/blob/2.3/src/main/java/spark/webserver/jetty/SocketConnectorFactory.java#L68-L82

    0 讨论(0)
提交回复
热议问题