def _parsePublisher(self, raw_publisher_string): """Parses publisher string which is a certificate attributes string, e.g. CN=Microsoft Corporation, O=Microsoft Corporation,L=Redmond, S=Washington, C=US @return: Organization string """ dn = DnParser().parse(raw_publisher_string) organization = dn.find_first("O") if organization: return organization.value
def _parsePublisher(self, raw_publisher_string): '''Parses publisher string which is a certificate attributes string, e.g. CN=Microsoft Corporation, O=Microsoft Corporation,L=Redmond, S=Washington, C=US @return: Organization string ''' dn = DnParser().parse(raw_publisher_string) organization = dn.find_first('O') if organization: return organization.value
def parse(self, javaCert): ''' Perform trasformation from java.security.X509Certificate to ssl_cert.X509Certificate @types: java.security.X509Certificate -> ssl_cert.X509Certificate ''' typeCert = javaCert.getType() if typeCert == CertificateTypes.X509: objParser = DnParser() subject = javaCert.getSubjectDN().getName() issuedBy = javaCert.getIssuerDN().getName() subjectDn = objParser.parse(subject) issuedByDn = objParser.parse(issuedBy) version = javaCert.getVersion() create = javaCert.getNotBefore() expires = javaCert.getNotAfter() serialNumber = self.__bytesToHex(BigInteger(str(javaCert.getSerialNumber())).toByteArray()) return X509Certificate(create, expires, LDAPDistinguishedObject(subjectDn, subject), LDAPDistinguishedObject(issuedByDn, issuedBy), serialNumber, javaCert.getSigAlgName(), typeCert, version) return None
def parse(self, javaCert): ''' Perform trasformation from java.security.X509Certificate to ssl_cert.X509Certificate @types: java.security.X509Certificate -> ssl_cert.X509Certificate ''' typeCert = javaCert.getType() if typeCert == CertificateTypes.X509: objParser = DnParser() subject = javaCert.getSubjectDN().getName() issuedBy = javaCert.getIssuerDN().getName() subjectDn = objParser.parse(subject) issuedByDn = objParser.parse(issuedBy) version = javaCert.getVersion() create = javaCert.getNotBefore() expires = javaCert.getNotAfter() serialNumber = self.__bytesToHex( BigInteger(str(javaCert.getSerialNumber())).toByteArray()) return X509Certificate( create, expires, LDAPDistinguishedObject(subjectDn, subject), LDAPDistinguishedObject(issuedByDn, issuedBy), serialNumber, javaCert.getSigAlgName(), typeCert, version) return None