私は第三者からの私のSSL証明書を使用しています - 私はSSL-ConfigまたはSSLContextを使用しますか?アッカでHTTP SSL Javaは
public HttpsConnectionContext useHttps(ActorSystem system) {
HttpsConnectionContext https = null;
try {
final char[] password = properties.keystorePassword().toCharArray();
final KeyStore ks = KeyStore.getInstance("PKCS12");
final InputStream keystore = WDService.class.getClassLoader().getResourceAsStream("wtkeystore.p12");
if (keystore == null) {
throw new RuntimeException("Keystore required!");
}
ks.load(keystore, password);
final KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance("SunX509");
keyManagerFactory.init(ks, password);
final TrustManagerFactory tmf = TrustManagerFactory.getInstance("SunX509");
tmf.init(ks);
final SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(keyManagerFactory.getKeyManagers(), tmf.getTrustManagers(), new SecureRandom());
final AkkaSSLConfig sslConfig = AkkaSSLConfig.get(system);
https = ConnectionContext.https(sslContext);
} catch (NoSuchAlgorithmException | KeyManagementException e) {
system.log().error(e.getCause() + " while configuring HTTPS.", e);
} catch (CertificateException | KeyStoreException | UnrecoverableKeyException | IOException e) {
system.log().error(e.getCause() + " while ", e);
}
return https;
次私はアッカHTTPSサポートドキュメントを参照して符号化している
openssl pkcs12 -export -CAfile Geotrust_EV_Intermediate_Bundle.crt -in www_domainName_in.crt -inkey domainName.in.key -out wtkeystore1.p12 -name CompanyName -passout pass:SomePassWord
次のコマンドを使用した.p12キーストアを作成しました}
私のメインファイルコード
final Http http = Http.get(system);
log.info("Starting on " + properties.url() + ":" + properties.port());
final ConnectHttp host = ConnectHttp.toHost(properties.url(), properties.port());
Http.get(system).bindAndHandle(appRoute().flow(system, materializer), host, materializer);
log.info("Started on " + properties.url() + ":" + properties.port());
if (properties.useSSL()) {
HttpsConnectionContext https = useHttps(system);
http.setDefaultServerHttpContext(https);
Http.get(system).bindAndHandle(appRoute().flow(system, materializer),
ConnectHttp.toHost(properties.urlSSL(), properties.portSSL()), materializer);
log.info("Started on " + properties.urlSSL() + ":" + properties.portSSL());
}
を以下のようです
今、私はAkka Httpにバインドすることができます。エラーは一切報告されませんが、httpsリクエストはサーバー上で拒否されます(akkaシステムにはエラーログもないのでakka/httpにも届きません)。http://domainName.inうまく動作します。
問題:私は上記のいずれかのステップが欠落し
アム?
私はSSLContextのみを使用しています - これはOKか、SSLConfigも使用しますか?はいの場合 - SSLConfigをどのように使用すればいいですか?適切な文書がないようです
- keytool経由でJavaのデフォルトキーストアを使用していますか?なぜなら私はopensslを使って生成されたwtkeystore.p12ファイルもキーストアであり、使用するのに十分なものだと考えているからです。
更新されたコード1: 提案されているよう:
if (properties.useSSL()) {
HttpsConnectionContext https = useHttps(system);
ConnectHttp connect = ConnectHttp.toHostHttps(properties.urlSSL(), properties.portSSL())
.withCustomHttpsContext(https);
Http.get(system).bindAndHandle(appRoute().flow(system, materializer), connect, materializer);
log.info("Started on " + properties.urlSSL() + ":" + properties.portSSL());
}
し、またファイアウォール/ネットワークポート443のために開いているが、 netstatのは、まだ「ESTABLISHED」と私のようにステータスが表示されていることを確認しましたこのポート接続は閉じられます。
私がデバッグすると、SSLConfigとその他のオブジェクトはNoneとなり、SSLContextオブジェクトは例外となります。これは普通ですか?
HTTPSサーバを作成するには、 'Connect.toHostHttps'を使う必要があります。 – jrudolph