我正在将我的单服务器 tomcat 迁移到集群,由 Apache HTTPD(使用 mod_proxy 进行反向代理)进行负载平衡和缓存。
是否可以将证书和密钥转换为 apache 格式,或者我必须重新颁发整个内容?
直接使用提取证书非常容易keytool
,提取私钥有点棘手(尽管您可以编写程序来执行此操作)。我建议结合使用keytool
and openssl
.
如果您的密钥库采用 PKCS#12 格式(.p12 文件),请跳过此步骤。使用以下命令将您的 JKS 存储转换为 PKCS12 存储keytool
(需要 Java 6+ 版本)
keytool -importkeystore -srckeystore thekeystore.jks \
-srcstoretype JKS \
-destkeystore thekeystore.p12 \
-deststoretype PKCS12
然后,使用 openssl 提取证书:
openssl pkcs12 -in thekeystore.p12 -clcerts -nokeys -out servercert.pem
提取私钥:
umask 0077
openssl pkcs12 -in thekeystore.p12 -nocerts -nodes -out serverkey.pem
umask 0022
请注意,因为-nodes
提取私钥时使用选项,私钥文件将不会受到保护(因为它必须没有密码才能被 Apache Httpd 使用),因此请确保没有其他人可以读取它。
然后,使用配置 Apache HttpdSSLCertificateFile http://httpd.apache.org/docs/2.2/mod/mod_ssl.html#sslcertificatefile and SSLCertificateKeyFile http://httpd.apache.org/docs/2.2/mod/mod_ssl.html#sslcertificatekeyfile分别指向证书文件和私钥文件。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)