F5 is upgrading its customer support chat feature on My.F5.com. Chat support will be unavailable from 6am-10am PST on 1/20/26. Refer to K000159584 for details.

Forum Discussion

tiwang_122270's avatar
tiwang_122270
Icon for Nimbostratus rankNimbostratus
Dec 06, 2013

regex to get username from certificate subject

hi out there I have a problem in getting the syntax correct for getting the username from the certificate in a apm policiy where I have added a custom expression in the visual editor and added a message box before where I can see that my subject gets correctly assigned

 

Valid Certificat - subject is CN=John Doe,OU=UserOU,DC=testdom,DC=dk but when I try to extract the username here I don't get syntax correct - I have tried several - lastly apm policy agent variable-assign /Common/pwless_auth_act_variable_assign_ag { variables { { expression "regexp {^CN\=(.+.+).*} \"[mcget {session.ssl.cert.subject}]\"" varname session.logon.last.username } } } help - any suggestions?

 

best regards /ti

 

2 Replies

  • Try this in your variable assignment agent:

    regexp {CN=[^,]+} [mcget {session.ssl.cert.subject}] CN; return $CN
    
  • tiwang's avatar
    tiwang
    Icon for Nimbostratus rankNimbostratus

    Hi Kevin Thanks for the reply - I got in the right direction with it - modified it a bit:

     

    regexp {(?x)(CN)=([^,]+)} [mcget {session.ssl.cert.subject}] match CN USER; return $USER this gives me the username only - need now a bit extra finish but in the right diretcion thanks /ti