Python Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript



Python Examples

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

More Examples...
String
Email Object
POP3
SMTP
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
DH Key Exchange
DSA
SSH Key
SSH
SSH Tunnel
SFTP

Unreleased...
Bzip2
LZW
Bz2
Icon

 

 

 

 

 

 

 

Load Digital Certificate from .cer Format File

Python script to load a .cer certificate file and display the properties of the digital certificate.

Download Python Programming Example Scripts

# file: LoadCertFile.py

import chilkat 

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

success = cert.LoadFromFile("tagtooga.cer")
if (not 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 = chilkat.SYSTEMTIME()
	cert.get_ValidFrom(sysTime0)
	
	sysTime1 = chilkat.SYSTEMTIME()
	cert.get_ValidTo(sysTime1)
	
	print "Valid from " + str(sysTime0.wMonth) + "/" + str(sysTime0.wDay) + "/" + str(sysTime0.wYear) + " to " + str(sysTime1.wMonth) + "/" + str(sysTime1.wDay) + "/" + str(sysTime1.wYear)
		






 

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

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