Export a Certificate to a .cer File
ASP script to export a certificate to a .cer certificate file.
<html>
<head>
<title>Export a Certificate to a .cer File</title>
</head>
<body>
<%
' Get an object to create a certificate store object
set ccs = Server.CreateObject("Chilkat_9_5_0.CreateCS")
' Open the local machine certificate store.
set certStore = ccs.OpenLocalSystemStore()
' Find the certificate matching the email address "matt@chilkatsoft.com"
set cert = certStore.FindCertBySubjectE("matt@chilkatsoft.com")
if (cert is Nothing) then
Response.write "Certificate not found!"
else
Response.write "Saving certificate: " & cert.SubjectDN & "<br>"
' Serialize the certificate to a string.
encodedCert = cert.GetEncoded()
set fs=Server.CreateObject("Scripting.FileSystemObject")
set f=fs.CreateTextFile("c:\temp\myCert.cer",true)
f.WriteLine(encodedCert)
f.Close
set f=nothing
set fs=nothing
end if
%>
</body>
</html>
|