I have an irule to extract specific X509 information from client certificate and pass it onto servers. Irule is working as expected, but application has the requirement to convert X509::serial_number into decimal. Currently it is being send in default Hex format. Below is the iRule i am using.
when CLIENTSSL_CLIENTCERT { set ssl_cert [SSL::cert 0] set sn [X509::serial_number $ssl_cert] set subject [X509::subject $ssl_cert] set issuer [X509::issuer $ssl_cert] set valid_from [X509::not_valid_before $ssl_cert] set valid_to [X509::not_valid_after $ssl_cert] session add uie [SSL::sessionid] [list $sn $issuer $subject $valid_from $valid_to] 1800 }
when CLIENTSSL_CLIENTCERT {
set ssl_cert [SSL::cert 0]
set sn [X509::serial_number $ssl_cert]
set decimal [expr $sn]
set subject [X509::subject $ssl_cert]
set issuer [X509::issuer $ssl_cert]
set valid_from [X509::not_valid_before $ssl_cert]
set valid_to [X509::not_valid_after $ssl_cert]
session add uie [SSL::sessionid] [list $decimal $issuer $subject $valid_from $valid_to] 1800
}
Or try to include something like this. I think the example above will not work, because the heximal representation of the serial includes the colon signs.
set fields [split $sn ":"]
set sn_decimal ""
foreach field $fields {
scan $field %x decimal
set sn_decimal [concat $sn_decimal$decimal]
}