Programming Examples

ChilkatHOMEASPVisual BasicVB.NETC#CC++MFCDelphiFoxProJavaPerlPythonRubySQL ServerVBScript

PHP ActiveX Examples

Bounced Mail
Bz2
Certificates/Keys
Charset
CSV
DKIM / DomainKey
Diffie-Hellman
DSA
Email Object
Encryption
FileAccess
FTP
HTML Conversion
HTTP
IMAP
MHT / HTML Email
MIME
NTLM
POP3
RSA
SMTP
Socket
Spider
SSH Key
SSH
SSH Tunnel
SFTP
Tar
Upload
XML
Zip
Amazon S3


 

 

 

 

 

 

 

 

Load PFX (PKCS#12) and List Certificates

Loads a PFX file (.pfx, .p12) and iterates over the certificates found within.

<?php

$certStore = new COM("Chilkat.CertStore");

$pfxPath = '/Users/chilkat/testData/pfx/chilkat_ssl.pfx';
$pfxPassword = 'test';
$success = $certStore->LoadPfxFile($pfxPath,$pfxPassword);
if ($success != true) {
    print $certStore->lastErrorText() . "\n";
    exit;
}

$numCerts = $certStore->NumCertificates;

print 'PFX contains ' . $numCerts . ' certificates' . "\n";

if ($numCerts == 0) {
    exit;
}

for ($i = 0; $i <= ($numCerts - 1); $i++) {

    // cert is a Chilkat.Cert
    $cert = $certStore->GetCertificate($i);
    if (!(is_null($cert))) {
        print $i . ': (Common Name) ' . $cert->subjectCN() . "\n";
        print $i . ': (Serial Number) ' . $cert->serialNumber() . "\n";
        print $i . ': (Distinguished Name) '
             . $cert->subjectDN() . "\n";

    }

}

?>

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2010 Chilkat Software, Inc. All Rights Reserved.