Forum Moderators: phranque
SetEnvIfExpr " %{SSL_PROTOCOL} =~ /TLSv1\.2/" ssl=ok
SetEnvIfExpr "! %{SSL_PROTOCOL} =~ /TLSv1\.2/" ssl=bad
SetEnvIfExpr " %{HTTP:SSL_PROTOCOL} =~ /TLSv1\.2/" ssl=ok if(isset($_SERVER['SSL_PROTOCOL'])) { $ssl=$_SERVER['SSL_PROTOCOL']; } else { $ssl=""; }
I have tried all of the lines below but they always trigger regardless of the SSL protocol status.
SetEnvIfExpr " %{SSL_PROTOCOL} =~ /TLSv1\.2/" ssl=ok
SetEnvIfExpr "! %{SSL_PROTOCOL} =~ /TLSv1\.2/" ssl=bad
SetEnvIfExpr " %{HTTP:SSL_PROTOCOL} =~ /TLSv1\.2/" ssl=ok
By "all the lines below" I meant separately, not together.
In PHP I have the following, which gives either the expected response.
This module can be configured to provide several items of SSL information as additional environment variables to the SSI and CGI namespace. Except for HTTPS and SSL_TLS_SNI which are always defined, this information is not provided by default for performance reasons.What are your current SSLOptions settings?
This per default is disabled for performance reasons, because the information extraction step is a rather expensive operation.Apache must really want to stress this point, since they say it twice on the same page.
When mod_ssl is built into Apache or at least loaded (under DSO situation) any variables provided by mod_ssl can be used in expressions for the ap_expr Expression Parser. The variables can be referenced using the syntax ``%{varname}''. Starting with version 2.4.18 one can also use the mod_rewrite style syntax ``%{SSL:varname}'' or the function style syntax ``ssl(varname)''.Example (using mod_headers)
Header set X-SSL-PROTOCOL "expr=%{SSL_PROTOCOL}"
Header set X-SSL-CIPHER "expr=%{SSL:SSL_CIPHER}"
This feature even works without setting the StdEnvVars option of the SSLOptions directive.
Strictly speaking you should have some anchors on your regex.Get it working first, tidy up by stages afterwards.
another env var called "SSL" being set on your system?Definitely not.
why you are setting another env var in Apache when all the logging is presumably handled by PHP anyway?This is not for logging. The intention is to use it as part of the access prohibition mechanism. It will incidentally be logged for my own analyser. But as I said above, "Get it working first".
What do you mean by "either"?A typo - I changed the way I wrote it.
SSL_PROTOCOL isn't strictly speaking a header fieldYes, I read that doc - several times - and came away still confused. I've assumed that is why setenv does not work but neither does an <if>. And in any case, why is the envar always set if the var cannot be tested?
What are your current SSLOptions settings?+StrictRequire
stress this pointYes, but how to enable it?
what version of apache are you running?version 2.4.18