git://git.onelab.eu
/
sfa.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
yet another srt / bytes issue in certificate
[sfa.git]
/
sfa
/
trust
/
certificate.py
diff --git
a/sfa/trust/certificate.py
b/sfa/trust/certificate.py
index
651bbc6
..
8174226
100644
(file)
--- a/
sfa/trust/certificate.py
+++ b/
sfa/trust/certificate.py
@@
-117,7
+117,7
@@
def convert_public_key(key):
(ssh_f, ssh_fn) = tempfile.mkstemp()
ssl_fn = tempfile.mktemp()
(ssh_f, ssh_fn) = tempfile.mkstemp()
ssl_fn = tempfile.mktemp()
- os.write(ssh_f, key)
+ os.write(ssh_f, key
.encode()
)
os.close(ssh_f)
cmd = keyconvert_path + " " + ssh_fn + " " + ssl_fn
os.close(ssh_f)
cmd = keyconvert_path + " " + ssh_fn + " " + ssl_fn
@@
-182,7
+182,7
@@
class Keypair:
# @param filename name of file to store the keypair in
def save_to_file(self, filename):
# @param filename name of file to store the keypair in
def save_to_file(self, filename):
- with open(filename, 'w') as output:
+ with open(filename, 'w
b
') as output:
output.write(self.as_pem())
self.filename = filename
output.write(self.as_pem())
self.filename = filename
@@
-191,6
+191,7
@@
class Keypair:
# public key.
def load_from_file(self, filename):
# public key.
def load_from_file(self, filename):
+ logger.info(f"opening {filename} from certficate.load_from_file")
self.filename = filename
buffer = open(filename, 'r').read()
self.load_from_string(buffer)
self.filename = filename
buffer = open(filename, 'r').read()
self.load_from_string(buffer)
@@
-678,6
+679,11
@@
class Certificate:
# raise "Cannot add extension {} which had val {} with new val {}"\
# .format(name, oldExtVal, value)
# raise "Cannot add extension {} which had val {} with new val {}"\
# .format(name, oldExtVal, value)
+ if isinstance(name, str):
+ name = name.encode()
+ if isinstance(value, str):
+ value = value.encode()
+
ext = OpenSSL.crypto.X509Extension(name, critical, value)
self.x509.add_extensions([ext])
ext = OpenSSL.crypto.X509Extension(name, critical, value)
self.x509.add_extensions([ext])