濮阳杆衣贸易有限公司

主頁(yè) > 知識(shí)庫(kù) > nginx代理服務(wù)器配置雙向證書(shū)驗(yàn)證的方法

nginx代理服務(wù)器配置雙向證書(shū)驗(yàn)證的方法

熱門(mén)標(biāo)簽:百應(yīng)電銷(xiāo)機(jī)器人靠譜嗎 如何在各種地圖標(biāo)注自己的地址 申請(qǐng)400電話(huà)號(hào)碼多少錢(qián) 遼寧電銷(xiāo)平臺(tái)外呼系統(tǒng)軟件 信陽(yáng)銷(xiāo)售外呼系統(tǒng)招商 營(yíng)銷(xiāo)電銷(xiāo)機(jī)器人招商 菏澤crm外呼系統(tǒng)價(jià)格 coreldraw地圖標(biāo)注 物超所值的400電話(huà)申請(qǐng)

生成證書(shū)鏈

用腳本生成一個(gè)根證書(shū), 一個(gè)中間證書(shū)(intermediate), 三個(gè)客戶(hù)端證書(shū).

中間證書(shū)的域名為 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

服務(wù)器

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;
  }
}

客戶(hù)端

curl \

 -I \

 -vv \

 -x https://localhost:8888/ \

 --proxy-cert client1.crt \

 --proxy-key client1.key \

 --proxy-cacert ca.crt \

 https://www.baidu.com/

總結(jié)

以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,謝謝大家對(duì)腳本之家的支持。如果你想了解更多相關(guān)內(nèi)容請(qǐng)查看下面相關(guān)鏈接

標(biāo)簽:廈門(mén) 泰安 湖北 瀘州 江西 江門(mén) 內(nèi)江 玉樹(shù)

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《nginx代理服務(wù)器配置雙向證書(shū)驗(yàn)證的方法》,本文關(guān)鍵詞  nginx,代理,服務(wù)器,配置,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問(wèn)題,煩請(qǐng)?zhí)峁┫嚓P(guān)信息告之我們,我們將及時(shí)溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無(wú)關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《nginx代理服務(wù)器配置雙向證書(shū)驗(yàn)證的方法》相關(guān)的同類(lèi)信息!
  • 本頁(yè)收集關(guān)于nginx代理服務(wù)器配置雙向證書(shū)驗(yàn)證的方法的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    靖安县| 景德镇市| 东台市| 综艺| 时尚| 昌江| 宣城市| 光泽县| 梨树县| 罗田县| 长治市| 汝阳县| 察哈| 高州市| 苗栗市| 鞍山市| 万山特区| 大安市| 轮台县| 微山县| SHOW| 鄯善县| 门头沟区| 宁海县| 泗洪县| 石河子市| 双柏县| 肃南| 万盛区| 瑞丽市| 汨罗市| 阿克苏市| 北票市| 汾西县| 鸡泽县| 灵璧县| 黔南| 本溪市| 五常市| 滦平县| 松江区|