自己署名証明書を使用して、akka-httpサーバー(localhost)上でセキュリティで保護された接続を確立しようとしています。私は成功していない。Akka Http HTTPS構成でChromeがERR_SSL_VERSION_OR_CIPHER_MISMATCHを返す
sslのAkka-httpドキュメントは少し曖昧です。私は少しでも情報を集めようと努力しましたが、まだこれを働かせることはできません。
私は以下のようなSSLトレイト作成:私はそうのように私のサーバーの起動に形質を追加
trait MySslConfiguration {
def serverContext: HttpsContext = {
val password = "password".toCharArray
val context = SSLContext.getInstance("TLSv1.2")
val keyStore = KeyStore.getInstance("jks")
val keyStoreResource = "/scruples_keystore.jks"
val keyManagerFactory = KeyManagerFactory.getInstance("SunX509")
val trustManagerFactory = TrustManagerFactory.getInstance("SunX509")
keyStore.load(getClass.getClassLoader.getResourceAsStream(keyStoreResource), password)
keyManagerFactory.init(keyStore, password)
trustManagerFactory.init(keyStore)
context.init(keyManagerFactory.getKeyManagers, trustManagerFactory.getManagers, new SecureRandom())
val sslParams = context.getDefaultSSLParameters
sslParams.setEndpointIdentificationAlgorithm("HTTPS")
HttpsContext(sslContext = context
sslParameters = Some(sslParams),
enabledProtocols = Some(List("TLSv1.2", "TLSv1.1", "TLSv1")))
}
}
を:
object Main extends App with Core with RestInterface with MySslConfiguration {
val metricRegistry = new com.codahale.metrics.MetricRegistry()
override implicit val injector = GlobalInjector.getInjector
override implicit val system: ActorSystem = injector.instance[ActorSystem]
override def config: Config = injector.instance[Config]
override implicit def executor: ExecutionContextExecutor = system.dispatcher
override val logger: LoggingAdapter = Logging(system, getClass)
override implicit val materializer: Materializer = ActorMaterializer()
val routes = allRoutes
Http().bindAndHandle(routes, config.getString("http.host"), config.getInt("http.port"), httpsContext = Some(serverContext))
自己署名JKSキーストアは、以下のように作成されました:
keytool -genkey -keyalg RSA -keysize 2048 -keystore scruples_keystore.jks -alias myalias
誰かが助けてくれますか?
私は間違っていますか?私は構成の問題があると確信していますが、それを理解するように見えることはできません。
もう1つの質問は、私がCAの適切な偽薬を使用していた場合、何が変わるのでしょうか?
感謝
Akka Httpは、独自の豊富なドキュメントを持つssl-configライブラリを使用しています。http://typesafehub.github.io/ssl- config /(これはPlay-WSから取得され、スタンドアロンのライブラリとして抽出され、現在はAkka-Httpでも使用されています)。またプロジェクトhttps://github.com/typesafehub/ssl-config –
を参照してください。正しい方向に私を指摘していただきありがとうございます。私はあなたが上に投稿したように私はまだそれを動作させることはできませんとして文書に記載されているように構成を追加しました。自己署名証明書のサンプルコード/設定を投稿してください。私は設定を作成し、 'SSLContext.getDefault'を呼び出して、サーバを起動する際にbindメソッドの' HTTPContext'を設定するのですか?私は 'ssl-config-ssl.default = true'を設定しようとしても、サーバがhttps要求に応答するのを得られませんでした – fintis