Forum Discussion
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"
- Stanislas_Piro2Cumulonimbus
Use this command to convert subject to an array with attribute name as key
array set dnparts [split [string map [list "\\," "," "," "|" " , " "|" " ," "|" ", " "|"] $subject_dn] "|="]
- uniAltostratus
Try something like this (but test it, because I haven't):
lassign [split $subject_dn ","] cn ou o
- JnonNimbostratus
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.
- uni_87886Cirrostratus
Try something like this (but test it, because I haven't):
lassign [split $subject_dn ","] cn ou o
- JnonNimbostratus
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.
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