2013-07-11 63 views
2

如何使Jetty 9在訪問密鑰庫時忽略keypass?如何使Jetty 9在訪問密鑰存儲時忽略keypass?

這裏是我做過什麼:

  • 我產生了我的域名證書在startssl.com
  • 我產生鏈式證書(礦山+ sub.class1.server.ca.pem + ca.pem)這樣openssl pkcs12 -export -inkey ssl.key -in /home/ubuntu/bundle.crt -out /home/ubuntu/bundle.pkcs12
  • 它們導入新的密鑰庫是這樣的:keytool -importkeystore -srckeystore /home/ubuntu/bundle.pkcs12 -srcstoretype PKCS12 -destkeystore /opt/jetty/etc/keystore
  • 出於某種原因,別名爲「1」,所以我改名爲「碼頭」像這樣keytool -changealias -alias "1" -destalias "jetty" -keystore /opt/jetty/etc/keystore -storepass storepwd
  • 請注意,我用storepwd這是碼頭髮行版默認密碼

jetty-ssl.xml包含此

<Configure id="sslContextFactory" class="org.eclipse.jetty.util.ssl.SslContextFactory"> 
    <Set name="KeyStorePath"><Property name="jetty.home" default="." />/<Property name="jetty.keystore" default="etc/keystore"/></Set> 
    <Set name="KeyStorePassword"><Property name="jetty.keystore.password" default="OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4"/></Set> 
    <Set name="KeyManagerPassword"><Property name="jetty.keymanager.password" default="OBF:1u2u1wml1z7s1z7a1wnl1u2g"/></Set> 
    <Set name="TrustStorePath"><Property name="jetty.home" default="." />/<Property name="jetty.truststore" default="etc/keystore"/></Set> 
    <Set name="TrustStorePassword"><Property name="jetty.truststore.password" default="OBF:1vny1zlo1x8e1vnw1vn61x8g1zlu1vn4"/></Set> 
    <Set name="EndpointIdentificationAlgorithm"></Set> 
    <Set name="ExcludeCipherSuites"> 
    <Array type="String"> 
     <Item>SSL_RSA_WITH_DES_CBC_SHA</Item> 
     <Item>SSL_DHE_RSA_WITH_DES_CBC_SHA</Item> 
     <Item>SSL_DHE_DSS_WITH_DES_CBC_SHA</Item> 
     <Item>SSL_RSA_EXPORT_WITH_RC4_40_MD5</Item> 
     <Item>SSL_RSA_EXPORT_WITH_DES40_CBC_SHA</Item> 
     <Item>SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA</Item> 
     <Item>SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA</Item> 
    </Array> 
    </Set> 

    <New id="sslHttpConfig" class="org.eclipse.jetty.server.HttpConfiguration"> 
    <Arg><Ref refid="httpConfig"/></Arg> 
    <Call name="addCustomizer"> 
     <Arg><New class="org.eclipse.jetty.server.SecureRequestCustomizer"/></Arg> 
    </Call> 
    </New> 
</Configure> 

現在,當我啓動這一切的美麗碼頭崩潰,下面的錯誤

2013-07-11 21:34:01.984:WARN:oejuc.AbstractLifeCycle:main: FAILED [email protected](/opt/jetty/etc/keystore,/opt/jetty/etc/keystore): java.security.UnrecoverableKeyException: Cannot recover key 
java.security.UnrecoverableKeyException: Cannot recover key 
    at sun.security.provider.KeyProtector.recover(KeyProtector.java:328) 
    at sun.security.provider.JavaKeyStore.engineGetKey(JavaKeyStore.java:138) 
    at sun.security.provider.JavaKeyStore$JKS.engineGetKey(JavaKeyStore.java:55) 
    at java.security.KeyStore.getKey(KeyStore.java:792) 
    at sun.security.ssl.SunX509KeyManagerImpl.<init>(SunX509KeyManagerImpl.java:131) 
    at sun.security.ssl.KeyManagerFactoryImpl$SunX509.engineInit(KeyManagerFactoryImpl.java:68) 
    at javax.net.ssl.KeyManagerFactory.init(KeyManagerFactory.java:259) 

哪個顯然密碼不匹配,因爲它期望/從Jetty附帶的默認密鑰庫中傳遞keypass​​3210。

這裏是我的certicifates(S):http://pastebin.com/raw.php?i=p8LhT50P 這是一個從keytool -list -keystore /opt/jetty/etc/keystore -storepass storepwd -storetype JKS -v

輸出它在哪裏設置?我該如何解決這個錯誤?

謝謝!

回答

7

有兩個密碼:密鑰庫密碼(KeyStorePassword)和密鑰密碼(KeyManagerPassword)。對於PKCS#12商店,它們是相同的。

由於您使用密鑰庫的密碼將密鑰從PKCS#12存儲導入到JKS存儲中,這並不意味着密鑰本身的密碼已更改,並且可能不是"keypwd"(Jetty的默認設置) 。嘗試用您的PKCS#12商店密碼替換KeyManagerPassword的值。

(請注意,在一般情況下,你不需要密鑰庫轉換,你也可以使用PKCS12作爲KeyStoreType。)

+0

出色答卷。 – Mafro34

+0

是否可以忽略keymanagerPassword?我沒有設置密鑰密碼,並導致控制檯要求我爲org.eclipse.jetty.ssl.keypassword,如果在NPE中留下空白結果: – vaibhav

+0

I「+1 KeyManagerPassword =密碼密碼」。 –

相關問題