Package pysmime :: Module util
[hide private]
[frames] | no frames]

Module util

source code

Some useful functions.

Classes [hide private]
  BadKeyringSource
Exception raised if selected Keyring source is not valid.
Functions [hide private]
 
BIO_from_buffer(data=None)
Returns a BIO oject for OpenSSL from input memory buffer
source code
 
BIO_from_file(fd)
Returns a BIO object for OpenSSL from input file descriptor
source code
 
BIO_from_file_path(file_path)
Returns a BIO object for OpenSSL from input file path
source code
boolean
set_keyring(smime, private_key, cert, keyring_source)
Sets private key and certificate for input smime object based on keyring source.
source code
M2Crypto.X509.X509 or None
set_certificate(cert, keyring_source)
Sets certificate for input x509 object based on keyring source.
source code
Function Details [hide private]

set_keyring(smime, private_key, cert, keyring_source)

source code 

Sets private key and certificate for input smime object based on keyring source.

Parameters:
  • smime (M2Crypto.SMIME) - the smime object to update with key and certificate data
  • private_key (filepath or M2Crypto.BIO or M2Crypto.EVP.PKey) - private key reference, could be from file, from memory or from pkcs11 smartcard, based on keyring_soruce input parameter
  • cert (filepath or M2Crypto.BIO or M2Crypto.X509.X509) - certificate, could be from filepath, from memory or from pkcs11 smartcard, based on keyring_soruce input parameter
  • keyring_source (str) - the type of the source for input certificate, used to recall the appropriate method for SMIME settings. Ammitted values are: file, memory, pkcs11.
Returns: boolean
True if a valid keyring source, else False
Raises:
  • BadKeyringSource - the selected Keyring source is not valid. Ammitted values are file, memory and pkcs11.

set_certificate(cert, keyring_source)

source code 

Sets certificate for input x509 object based on keyring source.

Parameters:
  • cert (filepath or M2Crypto.BIO or M2Crypto.X509.X509) - certificate, could be from filepath, from memory or from pkcs11 smartcard, based on keyring_soruce input parameter
  • keyring_source (str) - the type of the source for input certificate, used to recall the appropriate method for X509 settings. Ammitted values are: file, memory, pkcs11.
Returns: M2Crypto.X509.X509 or None
the new X509 certificate if a valid keyring source, else False
Raises:
  • BadKeyringSource - the selected Keyring source is not valid. Ammitted values are file, memory and pkcs11.