Forum Discussion
iRule to require client certificate and validate it
when HTTP_REQUEST {
if { [HTTP::uri] starts_with "/pattern" }
{HTTP::collect
SSL::cert mode require
SSL::renegotiate
set ssl_cert [SSL::cert 0]
set isMatch 0
set org "Company name"
set locality "Warszawa"
set name "www.f5.com.pl"
set country "PL"
set issorg "“Thawte Consulting (Pty) Ltd."
set isscn "Thawte SGC C"
set issctr "PL"
set subject_dn [X509::subject $ssl_cert]
set issuer_dn [X509::issuer $ssl_cert]
log "Client Certificate Received: $subject_dn, $issuer_dn"
if { ($subject_dn matches $org) and ($subject_dn matches $locality) and ($subject_dn matches $name) and ($subject_dn matches $country) and ($issuer_dn matches $issorg) and ($issuer_dn matches $isscn) and ($issuer_dn matches $issctr)}
{
log "Client Certificate Accepted: $subject_dn, $issuer_dn"
set isMatch 1
pool TestSSL}
if { $isMatch == 0 }
{
log "No Matching Client Certificate Was Found Using: $subject_dn"
reject
}
}
else
{
pool TEST
}
}
- Colin_Walker_12Historic F5 AccountWhat do you mean "help" with this code? Is it not working? How is it behaving? What is it you're trying to accomplish from a big picture?
- jarrod_40624
Nimbostratus
lol pwned - Leszek_Majewsk1
Nimbostratus
hi, - hoolio
Cirrostratus
Jarrod, you joined just to add "owned"? That's helpful... - Leszek_Majewsk1
Nimbostratus
Hi, - David_Holmes_9Historic F5 AccountL,
- Mahmoud_Eldeeb_
Cirrostratus
I have code is similar to what mentioned earlier
when CLIENT_ACCEPTED { set session_flag 0 } when CLIENTSSL_HANDSHAKE { if { [SSL::cert count] != 0 } { log "Client cert is OK; releasing HTTP request." HTTP::release } } when HTTP_REQUEST { if { [HTTP::uri] starts_with "/polcard/" } { log "Certificate required for: [HTTP::uri]" if { [SSL::cert count] == 0} { log "No cert found. Holding HTTP request until a client cert is presented..." HTTP::collect set session_flag 1 SSL::authenticate always SSL::authenticate depth 9 SSL::cert mode require SSL::renegotiate } else { log "crt OK" pool TestSSL HTTP::release } } else { log "No certificate needed for: [HTTP::uri]" pool Test } }
- Mahmoud_Eldeeb_
Cirrostratus
when CLIENT_ACCEPTED { set session_flag 0 } when CLIENTSSL_HANDSHAKE { if { [SSL::cert count] != 0 } { log "Client cert is OK; releasing HTTP request." HTTP::release } } when HTTP_REQUEST { if { [HTTP::uri] starts_with "/polcard/" } { log "Certificate required for: [HTTP::uri]" if { [SSL::cert count] == 0} { log "No cert found. Holding HTTP request until a client cert is presented..." HTTP::collect set session_flag 1 SSL::authenticate always SSL::authenticate depth 9 SSL::cert mode require SSL::renegotiate } else { log "crt OK" pool TestSSL HTTP::release } } else { log "No certificate needed for: [HTTP::uri]" pool Test } }
Recent Discussions
Related Content
* 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