Forum Discussion
Ted_51200
Nimbostratus
Apr 14, 2008Client SSL Cert Irule
I am looking to request a client ssl cert to happen only if a a spacific url is requested but ignore if not.
My Irule
when CLIENTSSL_CLIENTCERT {
set the_cert [SSL::cert 0]
set subject_dn [X509::subject $the_cert]
if { $subject_dn != "" }{
if { $debug }{ log "Client Certificate received: $subject_dn"}
}
}
when HTTP_REQUEST {
if { [HTTP::uri] starts_with "/secure/" } {
log "Certificate required for: [HTTP::uri]"
if { [SSL::cert count] == 0} {
log "Certificate not present. Passing to Login .....: [HTTP::uri]"
SSL::cert mode require
SSL::renegotiate
pool pool_xx
}
set pkiSubject [X509::subject $the_cert]
set pkiIssuer [X509::issuer $the_cert]
HTTP::header insert CLIENTSSL_Status [SSL::verify_result]
HTTP::header insert CLIENTSSL_StatusString [X509::verify_cert_error_string [SSL::verify_result]]
HTTP::header insert CLIENTSSL_CN $pkiSubject
HTTP::header insert CLIENTSSL_SSLIssuer $pkiIssuer
HTTP::header insert CLIENTSSL_SSLClientCertSN [X509::serial_number $the_cert]
}
}
- Ted_51200
Nimbostratus
when i go into the Local Traffic / Client SSL Profiles / EXTCLIENTSSL Profile - Stephen_Archer_Historic F5 AccountI've been trying to do a similar thing... and am also having problems. All I'm trying to do is to check a URI, and if it contains '/SecureURI', then perform client authentication, and if authorised (using the SOA_Trusted_Certs , forward to the secure pool using a serverSSL profile. If unauthorised, reject the connection.
- Ted_51200
Nimbostratus
I now have a working Irule, but only sends the SSL headers/Info on refresh... anyone have any idea why ? or how to correct it? - Nicolas_Menant
Employee
Hi,when CLIENTSSL_CLIENTCERT { log local0. "start CLIENTSSL_CLIENTCERT" set the_cert [SSL::cert 0] set pkiSubject [X509::subject $the_cert] set pkiIssuer [X509::issuer $the_cert] log local0. "end CLIENTSSL_CLIENTCERT" } when HTTP_REQUEST { log local0. "start HTTP_REQUEST, uri is [HTTP::uri]" if { [HTTP::uri] starts_with "/SLFCSSOCollector/ssl/" } { log local0. "URI /SLFCSSOCollector/ssl/ detected!" if { [SSL::cert count] == 0} { log local0. "no certificate found... force SSL" SSL::cert mode require SSL::renegotiate log local0. "end HTTP_REQUEST" } } else { log local0. "certificate found!" set the_cert [SSL::cert 0] set pkiSubject [X509::subject $the_cert] set pkiIssuer [X509::issuer $the_cert] HTTP::header insert CLIENTSSL_Status [SSL::verify_result] HTTP::header insert CLIENTSSL_StatusString [X509::verify_cert_error_string [SSL::verify_result]] HTTP::header insert CLIENTSSL_CN $pkiSubject HTTP::header insert CLIENTSSL_SSLIssuer $pkiIssuer HTTP::header insert CLIENTSSL_SSLClientCertSN [X509::serial_number $the_cert] HTTP::header insert CLIENTSSL_Cert [b64encode $the_cert] } }
- Ted_51200
Nimbostratus
im now using the following irule - Nicolas_Menant
Employee
Ok Thanks for your logging details !!when CLIENTSSL_HANDSHAKE { log local0. "client SSL Handshake" if { [SSL::cert count] > 0 } { log local0. "client SSL Handshake...HTTP released" HTTP::release } } when CLIENTSSL_CLIENTCERT { log local0. "start CLIENTSSL_CLIENTCERT" set the_cert [SSL::cert 0] set pkiSubject [X509::subject $the_cert] set pkiIssuer [X509::issuer $the_cert] log local0. "end CLIENTSSL_CLIENTCERT" } when HTTP_REQUEST { log local0. "start HTTP_REQUEST, uri is [HTTP::uri]" if { [HTTP::uri] starts_with "/SLFCSSOCollector/ssl/" } { log local0. "URI /SLFCSSOCollector/ssl/ detected!" if { [SSL::cert count] == 0} { HTTP::collect SSL::authenticate always SSL::authenticate depth 9 log local0. "no certificate found... force SSL" SSL::cert mode require SSL::renegotiate log local0. "end HTTP_REQUEST" } } else { log local0. "certificate found!" set the_cert [SSL::cert 0] set pkiSubject [X509::subject $the_cert] set pkiIssuer [X509::issuer $the_cert] HTTP::header insert CLIENTSSL_Status [SSL::verify_result] HTTP::header insert CLIENTSSL_StatusString [SSL::verify_result]] HTTP::header insert CLIENTSSL_CN $pkiSubject HTTP::header insert CLIENTSSL_SSLIssuer $pkiIssuer HTTP::header insert CLIENTSSL_SSLClientCertSN [X509::serial_number $the_cert] HTTP::header insert CLIENTSSL_Cert [b64encode $the_cert] } }
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects