当前位置: 首页>>代码示例>>Python>>正文


Python X509.load_cert_string方法代码示例

本文整理汇总了Python中M2Crypto.X509.load_cert_string方法的典型用法代码示例。如果您正苦于以下问题:Python X509.load_cert_string方法的具体用法?Python X509.load_cert_string怎么用?Python X509.load_cert_string使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在M2Crypto.X509的用法示例。


在下文中一共展示了X509.load_cert_string方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add_certificate

# 需要导入模块: from M2Crypto import X509 [as 别名]
# 或者: from M2Crypto.X509 import load_cert_string [as 别名]
def add_certificate(self, certificate):
		"""
		Certificates are either packed binary strings in DER format, or
		instances of m2crypto.X509.X509
		"""
		if not isinstance(certificate, X509.X509):
			try:
				certificate = X509.load_cert_string(certificate, X509.FORMAT_DER)
			except:  # pylint: disable=bare-except
				return 1

		newFingerprint = certificate.get_fingerprint()
		for oldcert in self.x509certs:
			if newFingerprint == oldcert.get_fingerprint():
				return -1

		self.x509certs.append(certificate)
		return 0 
开发者ID:rsmusllp,项目名称:eapeak,代码行数:20,代码来源:networks.py

示例2: get_cert_data

# 需要导入模块: from M2Crypto import X509 [as 别名]
# 或者: from M2Crypto.X509 import load_cert_string [as 别名]
def get_cert_data(self, network, cert_layer):
		cert_data = cert_layer.certificate[3:]
		tmp_certs = []
		while cert_data:
			if len(cert_data) < 4:
				break  # Length and 1 byte are at least 4 bytes
			tmp_length = struct.unpack('!I', '\x00' + cert_data[:3])[0]
			cert_data = cert_data[3:]
			if len(cert_data) < tmp_length:
				break  # I smell corruption
			tmp_certs.append(cert_data[:tmp_length])
			cert_data = cert_data[tmp_length:]
		for certificate in tmp_certs:
			try:
				certificate = X509.load_cert_string(certificate, X509.FORMAT_DER)
			except X509.X509Error:
				pass
			network.add_certificate(certificate) 
开发者ID:rsmusllp,项目名称:eapeak,代码行数:20,代码来源:parse.py

示例3: clean_certificate

# 需要导入模块: from M2Crypto import X509 [as 别名]
# 或者: from M2Crypto.X509 import load_cert_string [as 别名]
def clean_certificate(self):
        if not check_smime_status():
            raise forms.ValidationError(_('Improperly configured S/MIME: Email backend is incompatible'))
        try:
            from M2Crypto import X509
            certificate = self.cleaned_data['certificate']
            X509.load_cert_string(str(certificate))
        except ImportError:
            raise forms.ValidationError(_('Improperly configured S/MIME: missing dependencies'))
        except X509.X509Error:
            raise forms.ValidationError(_('Invalid certificate: unknown format'))
        return certificate 
开发者ID:certsocietegenerale,项目名称:FIR,代码行数:14,代码来源:forms.py

示例4: mk_cacert

# 需要导入模块: from M2Crypto import X509 [as 别名]
# 或者: from M2Crypto.X509 import load_cert_string [as 别名]
def mk_cacert():
    csr = {"CN": config.get('ca','cert_ca_name'),
           "key": {
               "algo": "rsa",
               "size": config.getint('ca','cert_bits')
               },
           "names": [
               {
                   "C": config.get('ca','cert_country'),
                   "L": config.get('ca','cert_locality'),
                   "O": config.get('ca','cert_organization'),
                   "OU": config.get('ca','cert_org_unit'),
                   "ST": config.get('ca','cert_state')
                   }
                     ]
           }
    try:
        start_cfssl()
        body = post_cfssl('api/v1/cfssl/init_ca',csr)
    finally:
        stop_cfssl()

    if body['success']:
        pk_str = body['result']['private_key']
        pk = EVP.load_key_string(body['result']['private_key'].encode('utf-8'))
        cert = X509.load_cert_string(body['result']['certificate'].encode('utf-8'))
        pkey = cert.get_pubkey()

        return pk_str, cert, pk, pkey
    else:
        raise Exception("Unable to create CA") 
开发者ID:keylime,项目名称:keylime,代码行数:33,代码来源:ca_impl_cfssl.py

示例5: find_certs

# 需要导入模块: from M2Crypto import X509 [as 别名]
# 或者: from M2Crypto.X509 import load_cert_string [as 别名]
def find_certs(self, network, newNetwork):
		for cert in network.findall('certificate'):
			if cert.get('encoding') == 'DER':
				newNetwork.add_certificate(X509.load_cert_string(base64.standard_b64decode(cert.text.strip()), X509.FORMAT_DER))
			elif cert.get('encoding') == 'PEM':
				newNetwork.add_certificate(X509.load_cert_string(base64.standard_b64decode(cert.text.strip()), X509.FORMAT_PEM)) 
开发者ID:rsmusllp,项目名称:eapeak,代码行数:8,代码来源:parse.py

示例6: __init__

# 需要导入模块: from M2Crypto import X509 [as 别名]
# 或者: from M2Crypto.X509 import load_cert_string [as 别名]
def __init__(self):
        self.request = current.request
        self.ssl_client_raw_cert = self.request.env.ssl_client_raw_cert

        # rebuild the certificate passed by the env
        # this is double work, but it is the only way
        # since we cannot access the web server ssl engine directly

        if self.ssl_client_raw_cert:

            x509 = X509.load_cert_string(
                self.ssl_client_raw_cert, X509.FORMAT_PEM)
            # extract it from the cert
            self.serial = self.request.env.ssl_client_serial or (
                '%x' % x509.get_serial_number()).upper()

            subject = x509.get_subject()

            # Reordering the subject map to a usable Storage map
            # this allows us a cleaner syntax:
            # cn = self.subject.cn
            self.subject = Storage(filter(None,
                                          map(lambda x:
                                              (x, map(lambda y:
                                                      y.get_data(
                                                      ).as_text(),
                                                      subject.get_entries_by_nid(subject.nid[x]))),
                                              subject.nid.keys()))) 
开发者ID:uwdata,项目名称:termite-visualizations,代码行数:30,代码来源:x509_auth.py


注:本文中的M2Crypto.X509.load_cert_string方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。