Skip to content

Commit

Permalink
ignore stderr from openssl when saving to a variable
Browse files Browse the repository at this point in the history
  • Loading branch information
pgombar committed Aug 7, 2019
1 parent 5346d4a commit 2347e0f
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions azurelinuxagent/common/utils/cryptutil.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,33 +47,29 @@ def gen_transport_cert(self, prv_file, crt_file):
"-out {2}").format(self.openssl_cmd, prv_file, crt_file)
rc = shellutil.run(cmd)
if rc != 0:
logger.error("Failed to create {0} and {1} certificates".format(
prv_file, crt_file))
logger.error("Failed to create {0} and {1} certificates".format(prv_file, crt_file))

def get_pubkey_from_prv(self, file_name):
if not os.path.exists(file_name):
raise IOError(errno.ENOENT, "File not found", file_name)
else:
cmd = "{0} pkey -in {1} -pubout 2>/dev/null".format(self.openssl_cmd,
file_name)
cmd = "{0} pkey -in {1} -pubout 2>/dev/null".format(self.openssl_cmd, file_name)
pub = shellutil.run_get_output(cmd)[1]
return pub

def get_pubkey_from_crt(self, file_name):
if not os.path.exists(file_name):
raise IOError(errno.ENOENT, "File not found", file_name)
else:
cmd = "{0} x509 -in {1} -pubkey -noout".format(self.openssl_cmd,
file_name)
cmd = "{0} x509 -in {1} -pubkey -noout 2>/dev/null".format(self.openssl_cmd, file_name)
pub = shellutil.run_get_output(cmd)[1]
return pub

def get_thumbprint_from_crt(self, file_name):
if not os.path.exists(file_name):
raise IOError(errno.ENOENT, "File not found", file_name)
else:
cmd = "{0} x509 -in {1} -fingerprint -noout".format(self.openssl_cmd,
file_name)
cmd = "{0} x509 -in {1} -fingerprint -noout 2>/dev/null".format(self.openssl_cmd, file_name)
thumbprint = shellutil.run_get_output(cmd)[1]
thumbprint = thumbprint.rstrip().split('=')[1].replace(':', '').upper()
return thumbprint
Expand Down

0 comments on commit 2347e0f

Please sign in to comment.