(Classic ASP) Get Public Key from Certificate PEM
Loads a certificate from a PEM file and gets the cert's 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")
success = cert.LoadFromFile("qa_data/certs/someCert.pem")
If (success <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( cert.LastErrorText) & "</pre>"
Response.End
End If
' Get the certificate's public key:
' pubkey is a Chilkat.PublicKey
Set pubkey = cert.ExportPublicKey()
If (cert.LastMethodSuccess <> 1) Then
Response.Write "<pre>" & Server.HTMLEncode( cert.LastErrorText) & "</pre>"
Response.End
End If
Response.Write "<pre>" & Server.HTMLEncode( pubkey.GetPem(0)) & "</pre>"
' OK.. we have the public key which can be used in other Chilkat classes/methods...
%>
</body>
</html>
|