mirror of
https://github.com/saltstack/salt.git
synced 2025-04-17 10:10:20 +00:00
Update for m2crypto changes removing lhash (#37578)
* Update for m2crypto changes removing lhash * linting issues
This commit is contained in:
parent
928462df1d
commit
5e80accd82
1 changed files with 16 additions and 7 deletions
|
@ -115,16 +115,25 @@ def _new_extension(name, value, critical=0, issuer=None, _pyfree=1):
|
|||
value.strip('0123456789abcdefABCDEF:') is not '':
|
||||
raise salt.exceptions.SaltInvocationError('value must be precomputed hash')
|
||||
|
||||
lhash = M2Crypto.m2.x509v3_lhash() # pylint: disable=no-member
|
||||
ctx = M2Crypto.m2.x509v3_set_conf_lhash(lhash) # pylint: disable=no-member
|
||||
#ctx not zeroed
|
||||
_fix_ctx(ctx, issuer)
|
||||
|
||||
x509_ext_ptr = M2Crypto.m2.x509v3_ext_conf(lhash, ctx, name, value) # pylint: disable=no-member
|
||||
try:
|
||||
ctx = M2Crypto.m2.x509v3_set_nconf()
|
||||
_fix_ctx(ctx, issuer)
|
||||
if ctx is None:
|
||||
raise MemoryError(
|
||||
'Not enough memory when creating a new X509 extension')
|
||||
x509_ext_ptr = M2Crypto.m2.x509v3_ext_conf(None, ctx, name, value)
|
||||
lhash = None
|
||||
except AttributeError:
|
||||
lhash = M2Crypto.m2.x509v3_lhash() # pylint: disable=no-member
|
||||
ctx = M2Crypto.m2.x509v3_set_conf_lhash(lhash) # pylint: disable=no-member
|
||||
#ctx not zeroed
|
||||
_fix_ctx(ctx, issuer)
|
||||
x509_ext_ptr = M2Crypto.m2.x509v3_ext_conf(lhash, ctx, name, value) # pylint: disable=no-member
|
||||
#ctx,lhash freed
|
||||
|
||||
if x509_ext_ptr is None:
|
||||
raise Exception
|
||||
raise M2Crypto.X509.X509Error(
|
||||
"Cannot create X509_Extension with name '{0}' and value '{1}'".format(name, value))
|
||||
x509_ext = M2Crypto.X509.X509_Extension(x509_ext_ptr, _pyfree)
|
||||
x509_ext.set_critical(critical)
|
||||
return x509_ext
|
||||
|
|
Loading…
Add table
Reference in a new issue