# PKI Authentication

**URL:** <https://www.ruby-forum.com/t/pki-authentication/130884>\
**Category:** Rails\
**Created:** [March 4, 2008, 7:18am UTC](https://www.ruby-forum.com/t/pki-authentication/130884 "2008-03-04T07:18:03Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [March 4, 2008, 7:18am UTC](https://www.ruby-forum.com/t/pki-authentication/130884/1 "2008-03-04T07:18:03Z")

</div>

I am working on project and I need to get the value stored in  
SSL\_CLIENT\_S\_DN\_CN . We have been doing PKI authentication for  
sometime  
in PHP by getting the value of $\_SERVER[“SSL\_CLIENT\_S\_DN\_CN”] .

Now that I am trying some stuff in Rails I can’t seem to get anywhere.  
I try to do what you do above and I get a “Bad Request” when I have  
SSLUserName SSL\_CLIENT\_S\_DN\_CN in the httpd-ssl.conf file. I am able  
to  
get up and running when I comment it out.

Here is my config:

SSLRandomSeed startup builtin  
SSLRandomSeed connect builtin  
SSLRandomSeed connect file:/dev/urandom 512

Listen 443

AddType application/x-x509-ca-cert .crt  
AddType application/x-pkcs7-crl .crl

SSLPassPhraseDialog builtin

SSLSessionCache “shmcb:/var/run/ssl\_scache(512000)”  
SSLSessionCacheTimeout 28800

SSLMutex “file:/var/run/ssl\_mutex”

\<VirtualHost \*:443\>  
\<Proxy balancer://mongrel\_cluster\>  
BalancerMember [http://127.0.0.1:3000](http://127.0.0.1:3000)

# General setup for the virtual host

ServerName [luther.example.com](http://luther.example.com)  
ServerAdmin removed\_email\_address@domain.invalid  
ErrorLog “/var/log/httpd-error.log”  
TransferLog “/var/log/httpd-access.log”

RequestHeader set X\_FORWARDED\_PROTO ‘https’  
SSLUserName SSL\_CLIENT\_S\_DN\_CN

ProxyPass / balancer://mongrel\_cluster/  
ProxyPassReverse / balancer://mongrel\_cluster/  
ProxyPreserveHost ON

#Rewrite the REMOTE\_USER env variable into the request header  
RewriteEngine On  
RewriteCond %{LA-U:REMOTE\_USER} (.+)  
RewriteRule . -[E=RU:%1]  
RequestHeader add X-FORWARDED-User %{RU}e

SSLEngine on  
SSLCipherSuite  
ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL

SSLCertificateFile “/usr/local/etc/apache22/ssl/luther.crt”  
SSLCertificateKeyFile “/usr/local/etc/apache22/ssl/privkey.pem”  
SSLCertificateChainFile “/usr/local/etc/apache22/ssl/chain.crt”

SSLCACertificatePath “/usr/local/etc/apache22/ssl.crt”  
SSLVerifyClient require  
SSLVerifyDepth 10

SSLOptions +StdEnvVars +ExportCertData

And in an controller I am just doing:

\<%= request.env['SSL\_CLIENT\_S\_DN\_CN'] %\>

also tried

\<%= request.env['HTTP-X-FORWARDED-SSL\_CLIENT\_S\_DN\_CN'] %\>

All I get is blank.

Any advice would be MUCH appreciated
