Hi everyone,
So awhile back with some assistance I was able to come up with a valid way to extract some data from a users ssl certificate for further processing down the line by way of setting a header.
The string in question looked something like this:
sno=760081+%280xb9911%29&subject=C%3DXX%2C+O%3Dexample.com%2C+OU%3DBLAHBLAH%2C+OU%3DPKI%2C+OU%3DEMPLOYEE%2C+CN%3DLAST.FIRST.MIDDLE.1234567890&validfrom=Jan++1+00%3A00%3A00+2017+GMT&validto=Jan+31+23%3A59%3A59+2018+GMT&issuer=C%3DX.X%2C+O%3Dexample.com%2C+OU%3DBLAHBLAH%2C+OU%3DPKI%2C+CN%3DCA.example.com&policy_oids=2.16.840.1.101.2.1.11.42
To do so i ended up using:
RewriteCond %{HTTP:Client-Cert} (CN%3D)([A-Z-\s']+\.)(?:[A-Z-\s']+\.)*(\d+)
RewriteRule (.*) - [E=USER:%2%3]
RequestHeader set ID %{USER}e
Which finally results in:
LAST.1234567890
Whats happening now:
There was recently a hardware device installed before our webservers which is replacing spaces with a + symbol (easy to deal with) & an apostrophe replaced with a %27 (not easy to handle),I was able to modify the condition to handle the + by simply using:
RewriteCond %{HTTP:Client-Cert} (CN%3D)([A-Z-\s'+]+\.)(?:[A-Z-\s'+]+\.)*(\d+)
And that solved the issue for spaces. However we really need to revert the %27 back to an apostrophe somehow, the network device installed is not capable of doing so, I'm left with using apache regex to attempt to do this.
Can anyone think of a way to do this inside the condition in order to avoid adding a ton of rules, or If this can be done at all?
Thanks for your time everyone!