Windows环境用Xampp自制证书(certificate), Chrome(版本 60.0.3112.90通过)
标题: Self signed certificate no longer valid as of Chrome 58
(Chrome58以后自制证书不再有效)
原文地址:
https://github.com/webpack/webpack-dev-server/issues/854
解决方法:
Xampp下载(XAMPP是最流行的PHP开发环境)
https://www.apachefriends.org/zh_cn/index.html
将这个bat文件
https://github.com/wilga/win-openssl-self-signed-san/blob/master/makeCert.bat
放到
X:\xampp\apache\bin
下
修改Line 10: SET HOSTNAME=example(自定义的域名)
保存后双击即可! 导入证书(放在受信任的根证书颁发机构下)
bat文件code:
1 @echo off 2 3 REM IN YOUR SSL FOLDER, SAVE THIS FILE AS: makeCERT.bat 4 REM AT COMMAND LINE IN YOUR SSL FOLDER, RUN: makecert 5 REM IT WILL CREATE THESE FILES: example.cnf, example.crt, example.key 6 REM IMPORT THE .crt FILE INTO CHROME Trusted Root Certification Authorities 7 REM REMEMBER TO RESTART APACHE OR NGINX AFTER YOU CONFIGURE FOR THESE FILES 8 9 REM PLEASE UPDATE THE FOLLOWING VARIABLES FOR YOUR NEEDS. 10 SET HOSTNAME=example 11 SET DOT=com 12 SET COUNTRY=US 13 SET STATE=KS 14 SET CITY=Olathe 15 SET ORGANIZATION=IT 16 SET ORGANIZATION_UNIT=IT Department 17 SET EMAIL=webmaster@%HOSTNAME%.%DOT% 18 19 ( 20 echo [req] 21 echo default_bits = 2048 22 echo prompt = no 23 echo default_md = sha256 24 echo x509_extensions = v3_req 25 echo distinguished_name = dn 26 echo: 27 echo [dn] 28 echo C = %COUNTRY% 29 echo ST = %STATE% 30 echo L = %CITY% 31 echo O = %ORGANIZATION% 32 echo OU = %ORGANIZATION_UNIT% 33 echo emailAddress = %EMAIL% 34 echo CN = %HOSTNAME%.%DOT% 35 echo: 36 echo [v3_req] 37 echo subjectAltName = @alt_names 38 echo: 39 echo [alt_names] 40 echo DNS.1 = *.%HOSTNAME%.%DOT% 41 echo DNS.2 = %HOSTNAME%.%DOT% 42 )>%HOSTNAME%.cnf 43 44 openssl req -new -x509 -newkey rsa:2048 -sha256 -nodes -keyout %HOSTNAME%.key -days 3560 -out %HOSTNAME%.crt -config %HOSTNAME%.cnf
然后, 将生成的文件 拷贝到 X:\xampp\apache\conf\ssl.crt
重启Apache就可以了