def import_signed(cls, name, certificate, private_key): """ Import a signed certificate and private key as a client protection CA. This is a shortcut method to the 3 step process: * Create CA with name * Import certificate * Import private key Create the CA:: ClientProtectionCA.import_signed( name='myclientca', certificate_file='/pathto/server.crt' private_key_file='/pathto/server.key') :param str name: name of client protection CA :param str certificate_file: fully qualified path or string of certificate :param str private_key_file: fully qualified path or string of private key :raises CertificateImportError: failure during import :raises IOError: failure to find certificate files specified :rtype: ClientProtectionCA """ json = {"name": name, "certificate": certificate} ca = ElementCreator(cls, json) try: ca.import_private_key(private_key) except CertificateImportError: ca.delete() raise return ca
def create_self_signed(cls, name, public_key_algorithm="rsa", life_time=365, key_length=2048, **kwargs): """ .. versionchanged:: 0.7.0 `prefix` and `password` argument deprecated in SMC > 6.5.1. Create a self signed client protection CA. To prevent browser warnings during decryption, you must trust the signing certificate in the client browsers. :param str name: Name of this ex: "SG Root CA" Used as Key. Real common name will be derivated at creation time with a uniqueId. :param public_key_algorithm: public key algorithm, either rsa, dsa or ecdsa :param str,int life_time: lifetime in days for CA :param int key_length: length in bits, either 1024 or 2048 :raises CreateElementFailed: creating element failed :raises ActionCommandFailed: failed to self sign the certificate :rtype: ClientProtectionCA """ json = {"name": name, "validity_time": life_time} ca = ElementCreator(cls, json) try: ca.make_request( method="create", json={ "algorithm": public_key_algorithm, "key_name": name, "key_size": key_length, "life_time": life_time, }, resource="generate_self_signed_cert", ) except ActionCommandFailed: ca.delete() raise return ca