示例#1
0
def SSLeay_version(type):
    """
    Return a string describing the version of OpenSSL in use.

    :param type: One of the SSLEAY_ constants defined in this module.
    """
    return _ffi.string(_lib.SSLeay_version(type))
示例#2
0
def SSLeay_version(type):
    """
    Return a string describing the version of OpenSSL in use.

    :param type: One of the SSLEAY_ constants defined in this module.
    """
    return _ffi.string(_lib.SSLeay_version(type))
示例#3
0
文件: SSL.py 项目: Lukasa/pyopenssl
 def wrapper(ssl, out, outlen, in_, inlen, arg):
     outstr = callback(
         Connection._reverse_mapping[ssl], _ffi.string(in_))
     self._npn_select_callback_args = [
         _ffi.new("unsigned char *", len(outstr)),
         _ffi.new("unsigned char[]", outstr),
     ]
     outlen[0] = self._npn_select_callback_args[0][0]
     out[0] = self._npn_select_callback_args[1]
     return 0
示例#4
0
    def get_servername(self):
        """
        Retrieve the servername extension value if provided in the client hello
        message, or None if there wasn't one.

        :return: A byte string giving the server name or :py:data:`None`.
        """
        name = _lib.SSL_get_servername(self._ssl, _lib.TLSEXT_NAMETYPE_host_name)
        if name == _ffi.NULL:
            return None

        return _ffi.string(name)
示例#5
0
文件: SSL.py 项目: yliuhb/pyopenssl
    def get_servername(self):
        """
        Retrieve the servername extension value if provided in the client hello
        message, or None if there wasn't one.

        :return: A byte string giving the server name or :py:data:`None`.
        """
        name = _lib.SSL_get_servername(self._ssl, _lib.TLSEXT_NAMETYPE_host_name)
        if name == _ffi.NULL:
            return None

        return _ffi.string(name)
示例#6
0
    def get_cipher_list(self):
        """
        Get the session cipher list

        :return: A list of cipher strings
        """
        ciphers = []
        for i in count():
            result = _lib.SSL_get_cipher_list(self._ssl, i)
            if result == _ffi.NULL:
                break
            ciphers.append(_native(_ffi.string(result)))
        return ciphers
示例#7
0
文件: SSL.py 项目: Lukasa/pyopenssl
    def get_next_proto_negotiated(self):
        """
        Get the protocol that was negotiated by NPN.
        """
        data = _ffi.new("unsigned char **")
        data_len = _ffi.new("unsigned int *")

        _lib.SSL_get0_next_proto_negotiated(self._ssl, data, data_len)

        if not data_len[0]:
            return ""
        else:
            return _ffi.string(data[0])
示例#8
0
    def get_cipher_list(self):
        """
        Get the session cipher list

        :return: A list of cipher strings
        """
        ciphers = []
        for i in count():
            result = _lib.SSL_get_cipher_list(self._ssl, i)
            if result == _ffi.NULL:
                break
            ciphers.append(_native(_ffi.string(result)))
        return ciphers
示例#9
0
    def get_cipher_version(self):
        """
        Obtain the protocol version of the currently used cipher.

        :returns: The protocol name of the currently used cipher
            or :py:obj:`None` if no connection has been established.
        :rtype: :py:class:`unicode` or :py:class:`NoneType`
        """
        cipher = _lib.SSL_get_current_cipher(self._ssl)
        if cipher == _ffi.NULL:
            return None
        else:
            version =_ffi.string(_lib.SSL_CIPHER_get_version(cipher))
            return version.decode("utf-8")
示例#10
0
文件: SSL.py 项目: samucc/pyopenssl
    def get_cipher_version(self):
        """
        Obtain the protocol version of the currently used cipher.

        :returns: The protocol name of the currently used cipher
            or :py:obj:`None` if no connection has been established.
        :rtype: :py:class:`unicode` or :py:class:`NoneType`
        """
        cipher = _lib.SSL_get_current_cipher(self._ssl)
        if cipher == _ffi.NULL:
            return None
        else:
            version = _ffi.string(_lib.SSL_CIPHER_get_version(cipher))
            return version.decode("utf-8")
示例#11
0
import sys
from OpenSSL import crypto
from OpenSSL._util import (
	ffi as _ffi,
	lib as _lib,
)

with open(sys.argv[1], 'rb') as f:
	p7data = f.read()
p7 = crypto.load_pkcs7_data(crypto.FILETYPE_ASN1, p7data)

bio_out =crypto._new_mem_buf()
res = _lib.PKCS7_verify(p7._pkcs7, _ffi.NULL, _ffi.NULL, _ffi.NULL, bio_out, _lib.PKCS7_NOVERIFY|_lib.PKCS7_NOSIGS)
if res == 1:
	databytes = crypto._bio_to_string(bio_out)
	print(databytes)
else:
	errno = _lib.ERR_get_error()
	errstrlib = _ffi.string(_lib.ERR_lib_error_string(errno))
	errstrfunc = _ffi.string(_lib.ERR_func_error_string(errno))
	errstrreason = _ffi.string(_lib.ERR_reason_error_string(errno))
	print(errstrreason)
示例#12
0
# How do I get the value of OpenSSL._util.lib.X509_verify_cert_error_string as a python string
from OpenSSL._util import ffi
ffi.string(lib.X509_verify_cert_error_string(errornum))
示例#13
0
# How do I get the value of OpenSSL._util.lib.X509_verify_cert_error_string as a python string
from OpenSSL._util import ffi

ffi.string(lib.X509_verify_cert_error_string(errornum))