Perl Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

Perl Examples

Quick Start
Perl Unicode
Perl Byte Array
Perl Certs
Perl Email
Perl Encryption
Perl FTP
HTML-to-XML
Perl HTTP
Perl IMAP
Perl MHT
Perl MIME
Perl RSA
Perl S/MIME
Perl Signatures
Perl Socket
Perl Spider
Perl Tar
Perl Upload
Perl XML
Perl XMP
Perl Zip

More Examples...
String
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor

Unreleased...
Service
PPMD
Deflate
Bzip2
LZW
Bz2
DH Key Exchange
DSA
Icon

 

 

 

 

 

 

 

Load .cer Digital Certificate File

Chilkat Module for Perl 5.8.*

Chilkat Module for Perl 5.10.*

Perl script to load a .cer file and access / print properties of the digital certificate.

# file: LoadCertFile.pl

use chilkat;

# How to load a .cer digital certificate and get information.
# The CkCert is a free utility class that can be used in any
# Perl application/script without the need to purchase a license.
$cert = new chilkat::CkCert();

$success = $cert->LoadFromFile("tagtooga.cer");
if (!$success)
{
	$cert->SaveLastError("lastError.txt");
}
else
{
	print "Subject Email: " . $cert->subjectE . "\n";
	print "Subject Country: " . $cert->subjectC . "\n";
	print "Subject State/Province: " . $cert->subjectS . "\n";
	print "Subject City/Locality: " . $cert->subjectL . "\n";
	print "Subject Organization/Company Name: " . $cert->subjectO . "\n";
	print "Subject Organizational Unit: " . $cert->subjectOU . "\n";
	print "Subject Common Name: " . $cert->subjectCN . "\n";
	print "Subject Distinguished Name: " . $cert->subjectDN . "\n";
	
	print "Issuer Email: " . $cert->issuerE . "\n";
	print "Issuer Country: " . $cert->issuerC . "\n";
	print "Issuer State/Province: " . $cert->issuerS . "\n";
	print "Issuer City/Locality: " . $cert->issuerL . "\n";
	print "Issuer Organization/Company Name: " . $cert->issuerO . "\n";
	print "Issuer Organizational Unit: " . $cert->issuerOU . "\n";
	print "Issuer Common Name: " . $cert->issuerCN . "\n";
	print "Issuer Distinguished Name: " . $cert->issuerDN . "\n";
	
	print "SHA1 Thumbprint: " . $cert->sha1Thumbprint . "\n";
	print "RFC822 Name: " . $cert->rfc822Name . "\n";
	print "Serial Number: " . $cert->serialNumber . "\n";
	
	# Is the certificate's signature verified?
	if ($cert->get_SignatureVerified())
	{
		print "Certificate signature verified\n";
	}
	else
	{
		print "Certificate signature not verified\n";
	}
	
	if ($cert->get_TrustedRoot())
	{
		print "Certificate has a trusted root\n";
	}
	else
	{
		print "Certificate does not have a trusted root\n";
	}
	
	if ($cert->get_Revoked())
	{
		print "Certificate has been revoked!\n";
	}
	else
	{
		print "Certificate NOT revoked\n";
	}
	
	if ($cert->get_Expired())
	{
		print "Certificate is expired!\n";
	}
	else
	{
		print "Certificate NOT expired\n";
	}
	
	if ($cert->get_IsRoot())
	{
		print "This is a root certificate\n";
	}
	else
	{
		print "This is NOT a root certificate\n";
	}
	
	if ($cert->HasPrivateKey())
	{
		print "A private key is found and available\n";
	}
	else
	{
		print "A private key is NOT found or there is no permission to access\n";
	}
	
	if ($cert->get_ForTimeStamping())
	{
		print "Intended use includes time stamping\n";
	}
	else
	{
		print "Intended use does not include time stamping\n";
	}
	
	if ($cert->get_ForCodeSigning())
	{
		print "Intended use includes code signing\n";
	}
	else
	{
		print "Intended use does not include code signing\n";
	}
	
	if ($cert->get_ForClientAuthentication())
	{
		print "Intended use includes client authentication\n";
	}
	else
	{
		print "Intended use does not include client authentication\n";
	}
	
	if ($cert->get_ForServerAuthentication())
	{
		print "Intended use includes server authentication\n";
	}
	else
	{
		print "Intended use does not include server authentication\n";
	}
	
	if ($cert->get_ForSecureEmail())
	{
		print "Intended use includes secure email\n";
	}
	else
	{
		print "Intended use does not include secure email\n";
	}

	$sysTime0 = new chilkat::SYSTEMTIME();
	$cert->get_ValidFrom($sysTime0);
	
	$sysTime1 = new chilkat::SYSTEMTIME();
	$cert->get_ValidTo($sysTime1);
	
	print "Valid from " . $sysTime0->{wMonth} . "/" . 
		$sysTime0->{wDay} . "/" . $sysTime0->{wYear} . 
		" to " . $sysTime1->{wMonth} . "/" . $sysTime1->{wDay} . 
		 "/" . $sysTime1->{wYear};
		
}




 

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

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