(Ruby) Find Certificate by Subject OU (Organizational Unit)
Demonstrates how to find a certificate having the specified subject organizational unit (OU).
Note: Requires Chilkat v10.1.2 or later.
require 'chilkat'
certStore = Chilkat::CkCertStore.new()
# This opens the Current User certificate store on Windows,
# On MacOS and iOS it opens the default Keychain.
readOnly = false
success = certStore.OpenCurrentUserStore(readOnly)
if (success == false)
print certStore.lastErrorText() + "\n";
exit
end
# Find the certificate having a Subject OU = "Secretaria da Receita Federal do Brasil - RFB".
json = Chilkat::CkJsonObject.new()
ou = "Secretaria da Receita Federal do Brasil - RFB"
json.UpdateString("OU",ou)
cert = Chilkat::CkCert.new()
success = certStore.FindCert(json,cert)
if (success == true)
# Show the full distinguished name of the certificate.
print "Found: " + cert.subjectDN() + "\n";
else
print "Not found." + "\n";
end
|