[英]converting http to https using self signed certificate
我想使用我的自签名证书将http请求转换为https。 如何创建我的密钥库文件并在密钥库中添加证书,如何使用此密钥库文件将http转换为https。
请解决这个问题
不确定是否有帮助,但是将此代码添加到htaccess中会将所有http重定向到https:
<VirtualHost *:80>
ServerName www.example.com
Redirect "/" "https://www.example.com/"
</VirtualHost >
<VirtualHost *:443>
ServerName www.example.com
# ... SSL configuration goes here
</VirtualHost >
您可以使用KEYTOOL以及下面的Keystore生成密钥对,命令将为您提供具有私有/公共密钥对的密钥库
keytool -genkeypair -keysize 2048 -keyalg RSA -alias tempAlias -keystore /temp.keystore -ext SAN=dns:abc.com,dns:localhost,ip:xx.xx.xx.xx
生成自签名证书使用以下命令
keytool -export -alias tempAlias -keystore /temp.keystore -file /temp.crt
要将证书导入您的trsutstore
keytool -import -alias tempAlias -file PATH_TO_CRT_FILE -keystore PATH_TO_TRUSTSTORE
根据服务器的不同,您可以配置服务器以发出请求HTTPS,例如在tomcat中,您需要将server.xml中的connector标签更新为如下所示的内容
<Connector SSLEnabled="true"
clientAuth="false"
keystoreFile=PATH_TO_KEYSTORE
keystorePass=KEYSTORE_PASSWORD maxThreads="150"
port="443" protocol="HTTP/1.1" scheme="https"
secure="true" sslProtocol="TLS"
truststoreFile=PATH_TO_TRUSTKEYSTORE
truststorePass=TRUSTSTORE_PASSWORD/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.