我正在嘗試設定一個具有 SSL 且也進行客戶端驗證的 NGINX 伺服器。由於某種原因它不起作用。如果我在兩個 Spring Boot 應用程式之間嘗試證書,它們就會起作用。所以證書是好的。我有以下 nginx 設定檔:
#user nobody;
worker_processes auto;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
server {
listen 443 ssl;
ssl_certificate D:/nginx/server.cer;
ssl_certificate_key D:/nginx/server.pkcs8;
ssl_verify_client on;
ssl_trusted_certificate D:/nginx/client.cer;
ssl_client_certificate D:/nginx/client.cer;
server_name localhost;
location / {
return 301 https://www.google.com/ ;
}
location /api/user {
proxy_pass http://localhost:8443/api/user ;
}
location /api/key {
proxy_pass http://localhost:8443/api/key ;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
如果我將其更改ssl_verify_client on;
為ssl_verify_client off;
我會得到我期望的結果。所以其餘的設定應該沒問題...我今天啟動了 NGINX,想獲得一些幫助。
證書是我創建的。沒有頒發者,沒有憑證鏈。自簽名證書。
提前致謝。
答案1
這些指令ssl_client_certificate
(ssl_trusted_certificate
如果您決定使用它)應該包含用於驗證用戶端憑證的 CA 憑證。變更這些指令以指向包含用於簽署用戶端憑證的 CA 憑證的檔案。