SSL / TLS客户端证书使用RewriteCond和Rewrite Rules进行身份validation,以敏感地redirect未经授权的通信
我终于写在这里,因为我非常努力地对抗apache,SSL / TLS和客户端证书authentication,应该使用证书的序列号来限制访问特定的API调用。 更好地解释一些细节: 用户必须能够访问: https:// {host} / apiv3xx / s?testing没有任何问题和限制,但对于以下url: https:// {host} / apiv3xx / x?action = login&user = blablabla为了执行呼叫,需要客户端证书。 我以为实施以下解决scheme: <Location /apiv3xx> SetEnv api 1 SSLOptions +StdEnvVars -ExportCertData SSLVerifyClient optional SSLVerifyDepth 10 </Location> 另外还有一些重写规则来控制逻辑: RewriteCond %{REQUEST_URI} ^/apiv3xx/ [NC] RewriteCond %{QUERY_STRING} action=log([^&]*)?(?=&|$) [NC,OR] RewriteCond %{QUERY_STRING} action=adm([^&]*)?(?=&|$) [NC,OR] RewriteCond %{QUERY_STRING} action=ctc([^&]*)?(?=&|$) [NC] RewriteCond %{SSL:SSL_CLIENT_M_SERIAL} !(01000000000140AAD72ACCXXXXXX|02000000000140BAD37F1XXXXXXX) […]