Forum Discussion
William_Them_99
Nimbostratus
Dec 22, 2005Client Certificate data format
I am trying to combine the client certificate functionality of iRules with a backend .NET application. Our iRule base 64 encodes the client certificate, then inserts it into the header and send...
William_Them_99
Nimbostratus
Jun 07, 2006Here is the code:
'create a file name for the temporary storage of the certificate to disk and its converted form
temp_file_name = "cert_PEM_" & Replace(Replace(DateTime.Now.TimeOfDay.ToString.Replace(".", "_"), ":", ""), " ", "") & ".cer"
temp_output_file_name = "cert_DER_" & Replace(Replace(DateTime.Now.TimeOfDay.ToString.Replace(".", "_"), ":", ""), " ", "") & ".cer"
file_save_result = SaveTextToFile(certificateContent, temp_file_name)
'create a new process that runs the CRL utility to dump the CRL file contents to a text file
CertConversion = System.Diagnostics.Process.Start(certConversionBatchPath, temp_file_name & " " & temp_output_file_name)
'wait until the process completes before continuing
CertConversion.WaitForExit(1000)
'close the process
CertConversion.Close()
CertConversion.Dispose()
CertConversion = Nothing
'using the created .cer file, load it as a certificate object
cert = X509Certificates.X509Certificate.CreateFromCertFile(temp_output_file_name)
'delete the temporary .cer file and its converted form
File.Delete(temp_file_name)
File.Delete(temp_output_file_name)
It depends on a free utility from Microsoft called CERTUTIL.EXE which you can Google and download. For some reason, I had problems in .NET calling CERTUTIL.EXE directly with the parameters, so I had to create a batch file with the following content:
CERTUTIL.EXE -decode -f %1 %2
Where %1 is the passed-in source filename and %2 is the passed-in output filename - so the code calls the batch file which then calls CERTUTIL.EXE
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
DevCentral Quicklinks
* 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
Discover DevCentral Connects
