WampServer启用https

生成CA私钥和CA自签名证书:
genrsa -aes128 -out ca/cakey.pem 2048
req -new -x509 -key ca/cakey.pem -out ca/ca.crt -outform PEM -config ./openssl.cnf
{
Country Name (2 letter code) [AU]:CN
State or Province Name (full name) [Some-State]:Shanghai
Locality Name (eg, city) []:Shanghai
Organization Name (eg, company) [Internet Widgits Pty Ltd]:companyX
Organizational Unit Name (eg, section) []:sectionX
Common Name (e.g. server FQDN or YOUR name) []:MyCA
Email Address []:[email protected]
}

生成服务器私钥和证书请求:
genrsa -aes128 -out server/serverkey.pem 2048
(
win32下不支持加密秘钥,
1、解密:rsa -in server/serverkey.pem -out server/server_noencrypt.pem
)

req -new -key server/serverkey.pem -out server/server.csr -outform PEM -config ./openssl.cnf
{
Country Name (2 letter code) [AU]:CN
State or Province Name (full name) [Some-State]:Shanghai
Locality Name (eg, city) []:Shanghai
Organization Name (eg, company) [Internet Widgits Pty Ltd]:companyX
Organizational Unit Name (eg, section) []:sectionX
Common Name (e.g. server FQDN or YOUR name) []:127.0.0.1
Email Address []:[email protected]

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:
}

用ca证书签名服务器/客户端证书:
ca -in server/server.csr -out server/server.crt -cert ca/ca.crt -keyfile ca/cakey.pem -config ./openssl.cnf
==========================================================
修改httpd.conf:
#LoadModule ssl_module modules/mod_ssl.so
#Include conf/extra/httpd-mpm.conf
去掉前边的#号
修改httpd-ssl.conf:
SSLCertificateFile    xxx/conf/key/server.crt    (服务器证书的位置) 
SSLCertificateKeyFile    xxx/conf/key/server.key (服务器私钥的位置) 
SSLCACertificateFile    xxx/key/conf/ca.crt      (CA根证书的位置,进行客户端验证时需要)
#SSLVerifyClient require               (去掉前面的‘#’号,进行客户端验证时需要) 
#SSLVerifyDepth  1                     (去掉前面的‘#’号,把10改为1,进行客户端验证时需要)
==========================================================
遇到错误:
【假如遇到apache无法启动的时候,可以选我的电脑-》管理-》事件检查器-》应用程序日志,打开apache的错误报告,会有提示哪里出错了,一般都可以找到原因。】

【Apache2.4配置SSL后启动报错:AH02577: Init: SSLPassPhraseDialog builtin is not supported on Win32 (key file C:/Apache24/conf/server.key)
原因是因为Win32平台不支持加密密钥,启动Apache时就产生了上述错误;
问题解决思路:既然不支持加密,就把server.key的文件解密(同时注释掉httpd-ssl.conf文件中SSLPassPhraseDialog)
解密:openssl rsa -in server.key.org -out server.key
打开httpd-ssl.conf 找到SSLPassPhraseDialog  builtin 在前面加上#】


1、Windows平台 
在windows命令行窗口下执行: 
1.查看所有的端口占用情况
C:\>netstat -ano
  协议    本地地址                     外部地址               状态                   PID
  TCP    127.0.0.1:1434         0.0.0.0:0              LISTENING       3236

2.查看指定端口的占用情况
C:\>netstat -aon|findstr "9050"
  协议    本地地址                     外部地址               状态                   PID
  TCP    127.0.0.1:9050         0.0.0.0:0              LISTENING       2016

3.查看PID对应的进程
C:\>tasklist|findstr "2016"
 映像名称                       PID 会话名              会话#       内存使用
 ========================= ======== ================
  tor.exe                     2016 Console                 0     16,064 K 

4.结束该进程
C:\>taskkill /f /t /im tor.exe

你可能感兴趣的:(C++)