代理背后的 WSO2 身份服务器 X509 身份验证

WSO2 Identity Server X509 Authentication Behind Proxy

我正在使用 WSO2 Identity Server 5.10。 我需要添加对 X509 身份验证的支持,我正在阅读有关 X509 证书身份验证的文档 here 为了添加配置,我必须按照建议 here

修改 catalina-server.xml.j2 文件

完成它的工作,但我有一个非常大的端口混合......无论如何让我们假设它工作。

现在我遇到了这个问题:我需要在 K8S 集群中部署 WSO2 Identity Server。所以,基本上,我有一个 nginx 入口控制器,它将管理到后端的所有流量。

我在本地做的是放置一个简单的 nginx 反向代理并配置 WSO2 Identity Server 以使用此代理。所以在我的deployment.toml中我做了以下

[custom_trasport.x509.properties]
protocols="HTTP/1.1"
port="8443"
maxThreads="200"
scheme="https"
secure=true
SSLEnabled=true
keystoreFile="mykeystore.jks"
keystorePass="pwd"
truststoreFile="myclient_trust.jks"
truststorePass="myclient_trust_pwd"
bindOnInit=false
clientAuth="want"
sslProtocol = "TLS"
proxyPort="443"


[authentication.authenticator.x509_certificate.parameters]
name ="x509CertificateAuthenticator"
enable=true
AuthenticationEndpoint="https://$ref{server.hostname}:8443/x509-certificate-servlet"
username= "CN"
SearchAllUserStores="false"
EnforceSelfRegistration = "false"
SearchAndValidateUserLocalStores = "false"


[transport.https.properties]
proxyPort="443"

这样,当我想使用 X509 证书身份验证登录时,它会要求我提供证书,但是当我选择证书时,它会显示错误,因为它无法在浏览器请求

此外,我认为我不应该离开 AuthenticationEndpoint="https://$ref{server.hostname}:8443/x509-certificate-servlet",因为这意味着提交将完成到永远不会在 Internet 上公开的 8443 端口。

有人解决了这个问题吗?基本上问题是:如何在代理(例如 nginx)后面配置 X509 证书身份验证?

任何小费都是非常宝贵的。

谢谢

安杰洛

我想我解决了我面临的问题。

基本上当我有 reverse_proxy(例如 nginx)时,证书不会到达请求属性中的 tomcat。

我所做的是配置 reverse_proxy 将证书作为 HTTP header 而不进行验证;我会在服务器端验证。

所以现在我的 nginx 配置是:

server {
        listen 443;
        server_name wso2_iam;
        ssl on;
        ssl_certificate certificate_full_path.crt;
        ssl_certificate_key full_path_to_kwy_no_pwd.key;
        ssl_verify_client optional_no_ca;

       
        location /x509-certificate-servlet/ {
                   proxy_set_header X-Forwarded-Host $host;
                   proxy_set_header X-Forwarded-Server $host;
                   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                   proxy_set_header Host $http_host;
                   proxy_set_header X-SSL-CERT $ssl_client_escaped_cert;
                   proxy_read_timeout 5m;
                   proxy_send_timeout 5m;
                   proxy_pass https://127.0.0.1:8443/x509-certificate-servlet;

                   proxy_http_version 1.1;
                   proxy_set_header Upgrade $http_upgrade;
                   proxy_set_header Connection "upgrade";
        }
        location / {
                   proxy_set_header X-Forwarded-Host $host;
                   proxy_set_header X-Forwarded-Server $host;
                   proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                   proxy_set_header Host $http_host;
                   proxy_set_header X-SSL-CERT $ssl_client_escaped_cert;
                   proxy_read_timeout 5m;
                   proxy_send_timeout 5m;
                   proxy_pass https://127.0.0.1:9443/;

                   proxy_http_version 1.1;
                   proxy_set_header Upgrade $http_upgrade;
                   proxy_set_header Connection "upgrade";
            }
        error_log  /var/log/nginx/wso2-error.log;
        access_log  /var/log/nginx/wso2-access.log;
}

ssl_verify_client optional_no_ca; 告诉 nginx 检索证书但不验证它。

proxy_set_header X-SSL-CERT $ssl_client_escaped_cert; 指令告诉 nginx 将基于请求 header 的证书 PEM 放入 X-SSL-CERT

然后我修改了 org.wso2.carbon.identity.authenticator.x509Certificate.X509CertificateAuthenticator 以便在 http 请求属性中找不到证书时在请求 header 之间搜索证书。

似乎有效。

谢谢大家

安杰洛