使用自签名证书将 http 转换为 https
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 与密钥库一起生成密钥对,下面的命令将为您提供具有私有/public 密钥对
的密钥库
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 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/>
我想使用我的自签名证书将我的 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 与密钥库一起生成密钥对,下面的命令将为您提供具有私有/public 密钥对
的密钥库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 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/>