Sample code for 30+ languages & platforms
Classic ASP

Find Certificate by Subject OU (Organizational Unit)

See more Cert Store Examples

Demonstrates how to find a certificate having the specified subject organizational unit (OU).

Note: Requires Chilkat v10.1.2 or later.

Chilkat Classic ASP Downloads

Classic ASP
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0

set certStore = Server.CreateObject("Chilkat.CertStore")

' This opens the Current User certificate store on Windows,
' On MacOS and iOS it opens the default Keychain.
readOnly = 0
success = certStore.OpenCurrentUserStore(readOnly)
If (success = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( certStore.LastErrorText) & "</pre>"
    Response.End
End If

' Find the certificate having a Subject OU = "Secretaria da Receita Federal do Brasil - RFB".
set json = Server.CreateObject("Chilkat.JsonObject")
ou = "Secretaria da Receita Federal do Brasil - RFB"
success = json.UpdateString("OU",ou)

set cert = Server.CreateObject("Chilkat.Cert")
success = certStore.FindCert(json,cert)
If (success = 1) Then
    ' Show the full distinguished name of the certificate.
    Response.Write "<pre>" & Server.HTMLEncode( "Found: " & cert.SubjectDN) & "</pre>"
Else
    Response.Write "<pre>" & Server.HTMLEncode( "Not found.") & "</pre>"
End If


%>
</body>
</html>