F5 Sites
  • F5.com
  • LearnF5
  • NGINX
  • MyF5
  • Partner Central
Contact
  • Under Attack?
  • F5 Support
  • DevCentral Support
  • F5 Sales
  • NGINX Sales
  • F5 Professional Services
Skip to contentBrand Logo
Forums
CrowdSRC
Articles
Groups
EventsSuggestionsHow Do I...?
RegisterSign In
  1. DevCentral
  2. Articles
  3. Technical Articles

Selective Client Cert Authentication

SSL encryption on the web is not a new concept to the general population of the internet. Those of us that frequent many websites per week (day, hour, minute, etc.) are quite used to making use of SS...
Published May 13, 2008
Version 1.0
adn
automation
BIG-IP
devops
management
monitoring
news
Colin_Walker_12's avatar
Colin_Walker_12
Historic F5 Account
Joined May 12, 2005
View Profile
Colin_Walker_12's avatar
Colin_Walker_12
Historic F5 Account
Joined May 12, 2005
View Profile
Peter_Z's avatar
Peter_Z
Icon for Cirrus rankCirrus
Jun 14, 2019

Hello, I need to build similar principle (request client cert) for selected URLs, but with one more additional condition: once client certificate is sent, I only want to allow clients with which belong to specific OU or comes from specific source IP.

It seems I cannot make it work.

I see the following error in ltm log:

 TCL error: /Common/https_vip <HTTP_REQUEST> - Error using <Certificate> (line 14)    invoked from within "X509::subject [SSL::cert 0]"    ("/test1/*" arm line 9)    invoked from within "switch -glob $uri {      "/test1/*" {        if { [SSL::cert count] <= 0 } {  HTTP::collect    SSL::authenticate alwa..."

iRule

when CLIENTSSL_CLIENTCERT {
  # release any stored data just in case
  HTTP::release
  # if there is still no cert after the SSL renegotiation kill the connection by sending a reset back to the client
  if { [SSL::cert count] < 1 } {
    reject
  }
}
 
when HTTP_REQUEST {
 set uri [HTTP::uri]
 
 switch -glob $uri {  
    "/test1/*" {
        if { [SSL::cert count] <= 0 } {
            HTTP::collect
            SSL::authenticate always
            SSL::authenticate depth 10
            SSL::cert mode require
            SSL::renegotiate
          
            set cert_subject [X509::subject [SSL::cert 0]] 
            set cert_issuer [X509::issuer [SSL::cert 0]]
 
            if { ($cert_subject contains "OU=Department1") || (($cert_subject contains "OU=Department2") && ($cert_subject contains "OU=PROD")) || ( [IP::addr [getfield [IP::client_addr] "%" 1] equals 192.168.20.1 ] ) } {
               pool pool1
            } else { 
               reject
            } 
        }
 
    }
  }    
}
 
when HTTP_REQUEST_SEND {
  clientside {
  # if there is a client side cert base64 encode it and inject it in the header
    if { [SSL::cert count] > 0 } {
      #log local0. "CLIENT CERT SUBJECT: [X509::subject [SSL::cert 0]]"
      HTTP::header insert "X-SSL-Session-ID"		[SSL::sessionid]
      HTTP::header insert "X-SSL-Client-Cert-Status"	[X509::verify_cert_error_string [SSL::verify_result]]
      HTTP::header insert "X-SSL-Client-Cert-Subject"	[X509::subject [SSL::cert 0]]
      HTTP::header insert "X-SSL-Client-Cert-Issuer"	[X509::issuer [SSL::cert 0]]
    }
  }
}

ABOUT DEVCENTRAL

DevCentral NewsTechnical ForumTechnical ArticlesTechnical CrowdSRCCommunity GuidelinesDevCentral EULAGet a Developer Lab LicenseBecome a DevCentral MVP

RESOURCES

Product DocumentationWhite PapersGlossaryCustomer StoriesWebinarsFree Online CoursesF5 CertificationLearnF5 Training

SUPPORT

Manage SubscriptionsProfessional ServicesProfessional ServicesCreate a Service RequestSoftware DownloadsSupport Portal

PARTNERS

Find a Reseller PartnerTechnology AlliancesBecome an F5 PartnerLogin to Partner Central

F5 logo©2024 F5, Inc. All rights reserved.
TrademarksPoliciesPrivacyCalifornia PrivacyDo Not Sell My Personal Information