简体   繁体   English

使用自签名证书将http转换为https

[英]converting http to https using self signed certificate

I want to convert my http request to https using my self signed certificate. 我想使用我的自签名证书将http请求转换为https。 How to create my keystore files and add certificate in keystore,how to use this keystore file for converting http to https. 如何创建我的密钥库文件并在密钥库中添加证书,如何使用此密钥库文件将http转换为https。

Please sort out this problem 请解决这个问题

Not sure if this helps but adding this code to htaccess will redirect all http to 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 >

You can use KEYTOOL to generate a keypair along with Keystore below command will give you keystore which will have the private / public keypair 您可以使用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

to generate Self Signed Certificate use below command 生成自签名证书使用以下命令

keytool -export -alias tempAlias -keystore /temp.keystore -file /temp.crt

To import a certificate into your trsutstore 要将证书导入您的trsutstore

keytool -import -alias tempAlias -file PATH_TO_CRT_FILE -keystore PATH_TO_TRUSTSTORE

Depending on the server you can configure the server to make the request HTTPS for example in tomcat you need to update the connector tag in server.xml to something like below 根据服务器的不同,您可以配置服务器以发出请求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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM