Beispiel #1
0
 def use_privatekey(self, _private_key):
     # At some point, we hope to use PyOpenSSL tooling to do this.  See #144.
     from OpenSSL._util import lib as _OpenSSLlib
     use_result = _OpenSSLlib.SSL_CTX_use_PrivateKey(
         self._context, _private_key._evp_pkey)
     if not use_result:
         self._raise_passphrase_exception()
Beispiel #2
0
    def use_privatekey(self, pkey):
        """
        Load a private key from a PKey object

        :param pkey: The PKey object
        :return: None
        """
        if not isinstance(pkey, PKey):
            raise TypeError("pkey must be a PKey instance")

        use_result = _lib.SSL_CTX_use_PrivateKey(self._context, pkey._pkey)
        if not use_result:
            self._raise_passphrase_exception()