相互 (双方向) 認証を使用するために、Tomcat 7 で実行されている Java Web サービスをセットアップしようとしています。何をしても、セキュア ポートでのサービスへの接続が機能していないようです。
証明書とキーストアなどを作成するために私がしたことは次のとおりです。
//create the key and certificate for the tomcat server.
keytool -genkey -v -alias tomcat -keyalg RSA -validity 3650 -keystore tomcat.keystore
//create the key and certificate for the client machine.
keytool -genkey -v -alias clientkey -keyalg RSA -storetype PKCS12 -keystore client.p12
//export the client key
keytool -export -alias clientkey -keystore client.p12 -storetype PKCS12 -rfc -file client.cer
//import the client key into the server keystore
keytool -import -v -file client.cer -keystore tomcat.keystore
server.xml ファイル内のコネクタは次のとおりです。
<Connector port="8443"
maxThreads="150"
scheme="https"
secure="true"
sslProtocol="TLS"
clientAuth="true"
keystoreFile="tomcat.keystore"
keystorePass="tomcat"
truststoreFile="tomcat.keystore"
truststorePass="tomcat"/>
tomcat-users.xml ファイルは次のようになります。
<tomcat-users>
<role rolename="tomcat"/>
<role rolename="admin"/>
<!-- note that the actual values for CN, OU, O, L, ST are different, but they match the values created in the client certificate -->
<user username="CN=name, OU=unit, O=org, L=locality, ST=state, C=US" password="null" roles="admin" />
</tomcat-users>
起動時に以下が設定されます。
-Djavax.net.ssl.keyStoreType=jks
-Djavax.net.ssl.keyStore=tomcat.keystore
-Djavax.net.ssl.keyStorePassword=tomcat
-Djavax.net.ssl.trustStore=tomcat.keystore
-Djavax.net.ssl.trustStorePassword=tomcat
-Djavax.net.debug=SSL
最後に、client.p12 ファイルをクライアント マシンにコピーし、Firefox のクライアント証明書にインポートしました。
最初の問題: Firefox から自分のサービス (例 - https://my.server.com:8443/test ) のエンドポイントに到達すると、「安全な接続に失敗しました」という応答が返されます。SSL は、許容される最大長を超えるレコードを受信しました。(エラーコード:ssl_error_rx_record_too_long)
2 番目の問題: このコネクタをポート 8443 で実行したくありません。ポート 7800 (当社の HTTPS の標準) で実行したいと考えています。コネクタのポートを 7800 に変更してエンドポイント (例 - https://my.server.com:7800/test ) にアクセスしようとすると、ページが解決されません。
だから、どこかで明らかに重要な部分が欠けています。誰でも私のエラーを見ることができますか?
更新: @Dave G からのフィードバック後
コマンドの実行:
openssl s_client -connect localhost:8443 -showcerts
次の出力が生成されます。
CONNECTED(00000003)
140642290976584:error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol:s23_clnt.c:766:
---
no peer certificate available
---
No client certificate CA names sent
---
SSL handshake has read 7 bytes and written 263 bytes
---
New, (NONE), Cipher is (NONE)
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
---
-Djavax.net.debug=SSL もスタートアップに追加しました。これにより、catalina.out ファイルの先頭に以下が生成されます。
trustStore is: tomcat.keystore
trustStore type is : jks
trustStore provider is :
init truststore
adding as trusted cert:
Subject: CN=localhost, OU=unit, O=org, L=Springfield, ST=MO, C=US
Issuer: CN=localhost, OU=unit, O=org, L=Springfield, ST=MO, C=US
Algorithm: RSA; Serial number: 0x5485b5a5
Valid from Mon Dec 08 14:28:53 UTC 2014 until Thu Dec 05 14:28:53 UTC 2024
adding as trusted cert:
Subject: CN=William Jackson, OU=unit, O=org, L=Springfield, ST=MO, C=US
Issuer: CN=William Jackson, OU=unit, O=org, L=Springfield, ST=MO, C=US
Algorithm: RSA; Serial number: 0x5485b6af
Valid from Mon Dec 08 14:33:19 UTC 2014 until Sun Mar 08 14:33:19 UTC 2015
trigger seeding of SecureRandom
done seeding SecureRandom
そして、たくさん:
Ignoring unavailable cipher suite: <suite name>
Ignoring unsupported cipher suite: <suite name>