2013年9月16日月曜日

Jetty SSL設定

Jetty 8.*での情報です
9.*でも利用可能かもしれません


#証明書作成用キーの作成

openssl genrsa -des3 -out jetty.key
openssl req -new -x509 -key jetty.key -out jetty.crt


#サーバへ送る証明書の作成

openssl req -new -key jetty.key -out jetty.csr


#2048bit以上が必要な場合
#openssl req -nodes -newkey rsa:2048 -keyout jetty.key -out jetty.csr


#keytoolがない場合${JAVA_HOME}/jre/bin/keytool



#証明書の登録
#jetty.csrの内容を証明サーバに送る
#jetty.crtに帰ってきた証明書を保存する
#keystoreへ登録

keytool -keystore keystore -import -alias jetty -file jetty.crt -trustcacerts



#pkcs12形式を登録
openssl pkcs12 -export -inkey jetty.key -in jetty.crt -certfile etc/SSL_CA.cer(中間証明書)  -out jetty.pkcs12
keytool -importkeystore -srckeystore jetty.pkcs12 -srcstoretype PKCS12 -destkeystore etc/keystore



#jetty-ssl.xml修正

<New id="sslContextFactory" class="org.eclipse.jetty.http.ssl.SslContextFactory">

    <Set name="KeyStore"><Property name="jetty.home" default="." />/etc/keystore</Set>

    <Set name="KeyStorePassword">[keystore password]</Set>

    <Set name="KeyManagerPassword">[key password]</Set>

    <Set name="TrustStore"><Property name="jetty.home" default="." />/etc/keystore</Set>

    <Set name="TrustStorePassword">[keystore password]</Set>

 </New>


#verify
openssl s_client -connect {対象サーバ}:443 -showcerts


参考
http://wiki.eclipse.org/Jetty/Howto/Configure_SSL

0 件のコメント: