XAMPP本地localhost配置HTTPS调试

最近在给CKeditor写一个获取location插件的时候,API要求必须使用https连接,于是学习了一下配置本地https调试的流程,记录一下过程

用openssl生成key和crt文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
xin@ubuntu:/opt/lampp/etc/ssl.crt$ sudo openssl req -x509 -nodes -days 36500 -newkey rsa:2048 -keyout ./server.key -out ./server.crt
Can't load /home/xin/.rnd into RNG
139698234061248:error:2406F079:random number generator:RAND_load_file:Cannot open file:../crypto/rand/randfile.c:88:Filename=/home/xin/.rnd
Generating a RSA private key
........+++++
.....................+++++
writing new private key to './server.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:CN
State or Province Name (full name) [Some-State]:Shandong
Locality Name (eg, city) []:Zaozhuang
Organization Name (eg, company) [Internet Widgits Pty Ltd]:
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:localhost
Email Address []:1583810565@qq.com

xin@ubuntu:/opt/lampp/etc/ssl.crt$ sudo mv server.key /opt/lampp/etc/ssl.key

配置apache

打开/opt/lampp/etc/extra/目录,里面有个httpd-ssl.conf文件,修改以下内容:

1
2
SSLCertificateFile "/opt/lampp/etc/ssl.crt/server.crt"
SSLCertificateKeyFile "/opt/lampp/etc/ssl.key/server.key"

保存后退出(记得用管理员权限)

httpd.conf也确认一下是否开启了SSL:

1
2
3
4
5
6
7
8
# Secure (SSL/TLS) connections
<IfModule ssl_module>
# XAMPP
<IfDefine SSL>
Include etc/extra/httpd-ssl.conf
</IfDefine>
</IfModule>
#

XAMPP本地localhost配置HTTPS调试
https://chujian521.github.io/blog/2020/06/28/XAMPP本地localhost配置HTTPS调试/
作者
Encounter
发布于
2020年6月28日
许可协议