# Irule for SSL client authentication

**URL:** <https://community.f5.com/t/irule-for-ssl-client-authentication/38256>\
**Category:** Technical Forums\
**Tags:** irules, dev, devops, application-delivery\
**Created:** [September 11, 2009, 12:50am UTC](https://community.f5.com/t/irule-for-ssl-client-authentication/38256 "2009-09-11T00:50:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![newbie\_89507](https://avatars.discourse-cdn.com/v4/letter/n/3bc359/32.png) [@newbie\_89507](https://community.f5.com/u/newbie_89507)\
**Post date:** [September 11, 2009, 12:50am UTC](https://community.f5.com/t/irule-for-ssl-client-authentication/38256/1 "2009-09-11T00:50:00Z")

</div>

i m new in this forum and new in F5 world. Recently bought F5 running 9.4.7 ver.

I have virtual server with valid SSL certificate. I need to write an irule so that when client try to connect to VS in f5 (which has valid cert) it ask client to present valid certificate once client presents valid certificate it will allow coonectivity. I also need to mention in irule that it checkes the certificate and allows only certifiacte specified in the irule not any valid ssl certificate.

URGENT URGENT URGENT URGENT URGENT URGENT URGENT URGENT URGENT URGENT URGENT URGENT URGENT URGENT URGENT URGENT URGENT URGENT URGENT URGENT URGENT URGENT URGENT URGENT URGENT URGENT URGENT URGENT URGENT URGENT URGENT URGENT URGENT

---

<div class="post-metadata">

**Author:** ![The\_Bhattman](https://d1p9zq3aats0t8.cloudfront.net/user_avatar/community.f5.com/the_bhattman/32/13958_2.png) [@The\_Bhattman](https://community.f5.com/u/The_Bhattman)\
**Post date:** [September 11, 2009, 2:22am UTC](https://community.f5.com/t/irule-for-ssl-client-authentication/38256/2 "2009-09-11T02:22:14Z")

</div>

hi Syed,

Have you looked at the following Sample Code

[http://devcentral.f5.com/wiki/default.aspx/iRules/ClientCertificateCNChecking.html](http://devcentral.f5.com/wiki/default.aspx/iRules/ClientCertificateCNChecking.html)

CB

---

<div class="post-metadata">

**Author:** ![newbie\_89507](https://avatars.discourse-cdn.com/v4/letter/n/3bc359/32.png) [@newbie\_89507](https://community.f5.com/u/newbie_89507)\
**Post date:** [September 11, 2009, 7:46am UTC](https://community.f5.com/t/irule-for-ssl-client-authentication/38256/3 "2009-09-11T07:46:41Z")

</div>

i want to authenticate via thumbprint and CN

---

<div class="post-metadata">

**Author:** ![newbie\_89507](https://avatars.discourse-cdn.com/v4/letter/n/3bc359/32.png) [@newbie\_89507](https://community.f5.com/u/newbie_89507)\
**Post date:** [September 11, 2009, 8:45am UTC](https://community.f5.com/t/irule-for-ssl-client-authentication/38256/4 "2009-09-11T08:45:17Z")

</div>

in this irule would be enough

class my\_thumbprint\_list {

“Thumbprint= 9e 0f 40 e2 43 1c”

}

3. Add this iRule:

when RULE\_INIT {

set ::org “O=my Organisation”

}

when CLIENTSSL\_CLIENTCERT {

Example Subject DN: /C=AU/ST=NSW/L=Syd/O=Your Organisation/OU=Your OU/CN=John Smith

set subject\_dn [X509::subject [SSL::cert 0]]

log “Client Certificate Received: $subject\_dn”

Check if the client certificate contains the correct O and a CN from the list

if { ([matchclass $subject\_dn contains $::my\_thumbprint\_list]) and ($subject\_dn contains $::org) } {

Accept the client cert

log “Client Certificate Accepted: $subject\_dn”

} else {

log “No Matching Client Certificate Was Found Using: $subject\_dn”

reject

}

}
