Determine if Certificate has a Private Key
ASP script to determine if a certificate has a private key available. A private key must be installed and available for
creating digital signatures, or for decrypting S/MIME or PKCS7 messages.
<html>
<head>
<title>Determine if a Private Key is Installed and Available</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()
' Iterate over the certificates
for i = 0 to certStore.NumCertificates - 1
set cert = certStore.GetCertificate(i)
' Show the name of the certificate and whether it has a private key.
Response.write cert.SubjectCN & ": "
if cert.HasPrivateKey() = 1 then
Response.Write "Certificate has a Private Key"
else
Response.Write "Certificate does NOT have a Private Key"
end if
Response.Write "<br><br>"
next
%>
</body>
</html>
|