# 建立 CA 目录结构 mkdir -p ./demoCA/{private,newcerts} touch ./demoCA/index.txt echo 01 > ./demoCA/serial # 生成 CA 的 RSA 密钥对 openssl genrsa -des3 -out ./demoCA/private/cakey.pem 2048 # 自签发CA证书 openssl req -new -x509 -days 365 -key ./demoCA/private/cakey.pem \ -out ./demoCA/cacert.pem # 把CA证书移至nghttpx配置目录 sudo mv ./demoCA/cacert.pem /etc/nghttpx/certs/ # 修改nghttpx启动脚本(supervisor) [program:nghttpx] command=nghttpx -s -f0.0.0.0,443 -b127.0.0.1,8080 /etc/nghttpx/certs/ssl.key /etc/nghttpx/certs/ssl.crt --verify-client --verify-client-cacert=/etc/nghttpx/certs/cacert.pem --npn-list=spdy/3.1,h2 autorestart=true user=root
接下来把vps上的cacert.pem和cakey.pem下载到本机并导入操作系统。在OSX中cacert.pem(公钥)双击导入即可,但cakey.pem(私钥)需从终端导入(GUI有Bug导不进):
security import cakey.pem -k ~/Library/Keychains/login.keychain
最后,理论上只要在Chrome安装扩展Proxy SwitchyOmega,设置好https proxy就万时大吉;但实际上Chrome 41 stable对需要证书认证的https代理有一个无限崩溃的Bug,所以需要更新到Chrome 43 dev或以上才行。当然Firefox 33以上已支持https proxy,需通过pac使用。