Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

Better option for multiple delimiters

I'm thinking there has to be a smarter way to accomplish what I'm doing here. I need to break out each value in the SSL Subject_dn, maybe a regex or ?? this is getting me what I need, but pretty sure there is a better way to accomplish this... any ideas appreciated.

if {[SSL::cert count ] > 0}{ set subject_dn [X509::subject [SSL::cert 0]] log local0. "this is the SSL Subject $subject_dn" set cn [getfield $subject_dn "," 1 ] set ou [getfield $subject_dn "," 2 ] set o [getfield $subject_dn "," 3 ] log local0. "CN=$cn, OU=$ou, O=$o" set cn2 [ getfield $cn "=" 2 ] set ou2 [ getfield $ou "=" 2 ] set o2 [ getfield $o "=" 2 ] log local0. "$cn2 $ou2 $o2"

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Try something like this (but test it, because I haven't):

lassign [split $subject_dn ","] cn ou o

0
Comments on this Answer
Comment made 12-Mar-2018 by Jnon 195

That looks like it's doing the same thing as getfields, it will get the variables for each CN, OU, O. but then it would need to be split again to remove the CN=, O=, OU= unless I'm missing something on how lassign work.

0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Use this command to convert subject to an array with attribute name as key

array set dnparts [split [string map [list "\\," "," "," "|" " , " "|" " ," "|" ", " "|"] $subject_dn] "|="]
0