91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

nginx 代理服務器配置雙向證書驗證的方法

發布時間:2020-10-16 09:36:27 來源:腳本之家 閱讀:187 作者:李毅 欄目:服務器

生成證書鏈

用腳本生成一個根證書, 一個中間證書(intermediate), 三個客戶端證書.

腳本來源于(有修改)
https://stackoverflow.com/questions/26759550/how-to-create-own-self-signed-root-certificate-and-intermediate-ca-to-be-importe

中間證書的域名為 localhost.

#!/bin/bash -x

set -e

for C in `echo root-ca intermediate`; do

 mkdir $C
 cd $C
 mkdir certs crl newcerts private
 cd ..

 echo 1000 > $C/serial
 touch $C/index.txt $C/index.txt.attr

 echo '
[ ca ]
default_ca = CA_default
[ CA_default ]
dir      = '$C'  # Where everything is kept
certs     = $dir/certs        # Where the issued certs are kept
crl_dir    = $dir/crl        # Where the issued crl are kept
database    = $dir/index.txt      # database index file.
new_certs_dir = $dir/newcerts      # default place for new certs.
certificate  = $dir/cacert.pem        # The CA certificate
serial     = $dir/serial        # The current serial number
crl      = $dir/crl.pem        # The current CRL
private_key  = $dir/private/ca.key.pem    # The private key
RANDFILE    = $dir/.rnd   # private random number file
nameopt    = default_ca
certopt    = default_ca
policy     = policy_match
default_days  = 365
default_md   = sha256

[ policy_match ]
countryName      = optional
stateOrProvinceName  = optional
organizationName    = optional
organizationalUnitName = optional
commonName       = supplied
emailAddress      = optional

[req]
req_extensions = v3_req
distinguished_name = req_distinguished_name

[req_distinguished_name]

[v3_req]
basicConstraints = CA:TRUE
' > $C/openssl.conf
done

openssl genrsa -out root-ca/private/ca.key 2048
openssl req -config root-ca/openssl.conf -new -x509 -days 3650 -key root-ca/private/ca.key -sha256 -extensions v3_req -out root-ca/certs/ca.crt -subj '/CN=Root-ca'

openssl genrsa -out intermediate/private/intermediate.key 2048
openssl req -config intermediate/openssl.conf -sha256 -new -key intermediate/private/intermediate.key -out intermediate/certs/intermediate.csr -subj '/CN=localhost.'
openssl ca -batch -config root-ca/openssl.conf -keyfile root-ca/private/ca.key -cert root-ca/certs/ca.crt -extensions v3_req -notext -md sha256 -in intermediate/certs/intermediate.csr -out intermediate/certs/intermediate.crt

mkdir out

for I in `seq 1 3` ; do
 openssl req -new -keyout out/$I.key -out out/$I.request -days 365 -nodes -subj "/CN=$I.example.com" -newkey rsa:2048
 openssl ca -batch -config root-ca/openssl.conf -keyfile intermediate/private/intermediate.key -cert intermediate/certs/intermediate.crt -out out/$I.crt -infiles out/$I.request
done

服務器

nginx 配置

worker_processes 1;

events {
  worker_connections 1024;
}

stream{
  upstream backend{
    server 127.0.0.1:8080;
  }

  server {
    listen 8888 ssl;
    proxy_pass backend;
    ssl_certificate   intermediate.crt;
    ssl_certificate_key intermediate.key;
    ssl_verify_depth 2;
    ssl_client_certificate root.crt;
    ssl_verify_client optional_no_ca;
  }
}

客戶端

curl \
 -I \
 -vv \
 -x https://localhost:8888/ \
 --proxy-cert client1.crt \
 --proxy-key client1.key \
 --proxy-cacert ca.crt \
 https://www.baidu.com/

以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支持億速云。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

东莞市| 仙桃市| 廊坊市| 垫江县| 东光县| 收藏| 志丹县| 兴海县| 景德镇市| 大兴区| 台东县| 化州市| 洪泽县| 水城县| 乌审旗| 济宁市| 浦城县| 泾源县| 祁门县| 施甸县| 尚志市| 利津县| 博白县| 日喀则市| 景谷| 汤原县| 杨浦区| 五指山市| 手游| 丁青县| 边坝县| 涟源市| 大冶市| 巢湖市| 玉田县| 房产| 攀枝花市| 衡东县| 宣武区| 阆中市| 淮安市|