def convert_public_key(key):
keyconvert_path = "/usr/bin/keyconvert.py"
if not os.path.isfile(keyconvert_path):
def convert_public_key(key):
keyconvert_path = "/usr/bin/keyconvert.py"
if not os.path.isfile(keyconvert_path):
(ssh_f, ssh_fn) = tempfile.mkstemp()
ssl_fn = tempfile.mktemp()
(ssh_f, ssh_fn) = tempfile.mkstemp()
ssl_fn = tempfile.mktemp()
# that it can be expected to see why it failed.
# TODO: for production, cleanup the temporary files
if not os.path.exists(ssl_fn):
# that it can be expected to see why it failed.
# TODO: for production, cleanup the temporary files
if not os.path.exists(ssl_fn):
# Returns a string containing the public key represented by this object.
def get_pubkey_string(self):
# Returns a string containing the public key represented by this object.
def get_pubkey_string(self):
return self.as_pem() == pkey.as_pem()
def sign_string(self, data):
return self.as_pem() == pkey.as_pem()
def sign_string(self, data):
k.sign_init()
k.sign_update(data)
return base64.b64encode(k.sign_final())
def verify_string(self, data, sig):
k.sign_init()
k.sign_update(data)
return base64.b64encode(k.sign_final())
def verify_string(self, data, sig):
return getattr(self,'filename',None)
def dump (self, *args, **kwargs):
return getattr(self,'filename',None)
def dump (self, *args, **kwargs):
- raise Exception, "Cannot set basicConstraints CA:?? more than once. Was %s, trying to set as %s" % (self.isCA, val)
+ raise Exception("Cannot set basicConstraints CA:?? more than once. Was %s, trying to set as %s" % (self.isCA, val))
def set_data(self, str, field='subjectAltName'):
# pyOpenSSL only allows us to add extensions, so if we try to set the
# same extension more than once, it will not work
def set_data(self, str, field='subjectAltName'):
# pyOpenSSL only allows us to add extensions, so if we try to set the
# same extension more than once, it will not work
# Return the data string that was previously set with set_data
def get_data(self, field='subjectAltName'):
# Return the data string that was previously set with set_data
def get_data(self, field='subjectAltName'):
# @param pkey is a Keypair object representing a public key. If Pkey
# did not sign the certificate, then an exception will be thrown.
# @param pkey is a Keypair object representing a public key. If Pkey
# did not sign the certificate, then an exception will be thrown.
# pyOpenSSL does not have a way to verify signatures
m2x509 = X509.load_cert_string(self.save_to_string())
# pyOpenSSL does not have a way to verify signatures
m2x509 = X509.load_cert_string(self.save_to_string())
return getattr(self,'filename',None)
def dump (self, *args, **kwargs):
return getattr(self,'filename',None)
def dump (self, *args, **kwargs):