Sample code for 30+ languages & platforms
Ruby

Find a Certificate in the "Other People" Windows Certificate Store

See more Certificates Examples

Demonstrates how to open the "Current User --> Other People" Windows certificate store, and locates a certificate matching an email address.

Chilkat Ruby Downloads

Ruby
require 'chilkat'

success = false

certStore = Chilkat::CkCertStore.new()

# The "AddressBook" is the "Other People" certificate store as shown in certmgr.msc
readOnly = true
success = certStore.OpenWindowsStore("CurrentUser","AddressBook",readOnly)
if (success != true)
    print certStore.lastErrorText() + "\n";
    exit
end

# Find the certificate for the email address:
jsonE = Chilkat::CkJsonObject.new()
jsonE.UpdateString("email","joe@example.com")

cert = Chilkat::CkCert.new()
success = certStore.FindCert(jsonE,cert)
if (success == false)
    print certStore.lastErrorText() + "\n";
    exit
end

print "Found certificate: " + cert.subjectDN() + "\n";