def get_certificate(self, filename): """ Return a certificate object by giving the name in the apk file """ import chilkat cert = chilkat.CkCert() f = self.get_file(filename) success = cert.LoadFromBinary(f, len(f)) return success, cert
def grab_certificate(apk, filename): """ @param apk : an APK instance @rtype : a certificate object by giving the name in the apk file """ try: import chilkat cert = chilkat.CkCert() f = apk.get_file(filename) success = cert.LoadFromBinary(f, len(f)) return success, cert except ImportError: log.error( "The Chilkat module is not installed, you will not have information about the certificate in the generated report" ) return False, []
#Copyright - Ajin Abraham - GPL3 from xml.dom.minidom import parse import xml.dom.minidom import sys import chilkat cert = chilkat.CkCert() print "Tizen Certificate Validator" x=raw_input("Enter Path to author-signature.xml or signature1.xml: ") DOMTree = xml.dom.minidom.parse(x) collection = DOMTree.documentElement if collection: print "Extracting Certificate Information From: " + x certs = collection.getElementsByTagName("X509Certificate") for c in certs: dat=str(c.firstChild.nodeValue) success = cert.LoadFromBase64(dat) if (success != True): print(cert.lastErrorText()) sys.exit() print("\n\n") print("SubjectDN:" + cert.subjectDN()) print("Common Name:" + cert.subjectCN()) print("Issuer Common Name:" + cert.issuerCN()) print("Serial Number:" + cert.serialNumber()) print("SHA1:" + cert.sha1Thumbprint()) print("Version: " + str(cert.get_CertVersion())) print("Valid from: " + cert.validFromStr() + " until: "+ cert.validToStr()) sys.exit() else: print "Error: Invalid File" sys.exit()
mailman = chilkat.CkMailMan() # Any string argument automatically begins the 30-day trial. success = mailman.UnlockComponent("Anything for 30-day trial") if (success != True): print(mailman.lastErrorText()) sys.exit() # Set the SMTP server. mailman.put_SmtpHost("smtp.mymailserver.com") # Load each recipient's certificate into a Chilkat certificate object. # This example loads the certificates from files. However, the Chilkat # certificate object provides other means for loading certificates, # such as from in-memory PEM strings, or in-memory binary DER encoded form, etc. cert1 = chilkat.CkCert() success = cert1.LoadFromFile("recipient1.cer") if (success != True): print(cert1.lastErrorText()) sys.exit() cert2 = chilkat.CkCert() success = cert2.LoadFromFile("recipient2.cer") if (success != True): print(cert2.lastErrorText()) sys.exit() cert3 = chilkat.CkCert() success = cert3.LoadFromFile("recipient3.cer") if (success != True): print(cert3.lastErrorText())
# Indicate the inner symmetric encryption algorithm to be used. # possible values are "aes", "des", "3des", and "rc2". # For this example, we'll use 256-bit AES encryption. crypt.put_Pkcs7CryptAlg("aes") crypt.put_KeyLength(256) # To encrypt, only a certificate w/ public key is needed. # (The certificate w/ private key is required for decryption.) # The LoadFromFile method can load virtually any certificate format: # 1. DER encoded binary X.509 (.CER) # 2. Base-64 encoded X.509 (.CER) # 3. Cryptographic Message Syntax Standard - PKCS #7 Certificates (.P7B) # 4. PEM format encryptCert = chilkat.CkCert() success = encryptCert.LoadFromFile("/Users/chilkat/testData/cer/acme.cer") if (success != True): print(encryptCert.lastErrorText()) sys.exit() # Tell the crypt object to use the certificate for encrypting: crypt.AddEncryptCert(encryptCert) # Encrypt a file, producing a .p7m as output. # The input file is unchanged, the output .p7m contains the encrypted # contents of the input file. inFile = "/Users/chilkat/testData/pdf/sample.pdf" outFile = "/Users/chilkat/testData/p7m/sample.pdf.p7m" success = crypt.CkEncryptFile(inFile, outFile) if (success != True):