(Classic ASP) Get Certificate's Public Key
Loads a certificate from PEM and gets the public key.
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
' For versions of Chilkat < 10.0.0, use CreateObject("Chilkat_9_5_0.Cert")
set cert = Server.CreateObject("Chilkat.Cert")
strPem = "-----BEGIN CERTIFICATE----- ..."
success = cert.LoadPem(strPem)
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( cert.LastErrorText) & "</pre>"
Response.End
End If
' pubKey is a Chilkat.PublicKey
Set pubKey = cert.ExportPublicKey()
If (cert.LastMethodSuccess = 0) Then
Response.Write "<pre>" & Server.HTMLEncode( cert.LastErrorText) & "</pre>"
Response.End
End If
' You can now use the public key object however it is needed,
' and access its various properties and methods..
Response.Write "<pre>" & Server.HTMLEncode( pubKey.GetXml()) & "</pre>"
%>
</body>
</html>
|