Skip to content

Commit

Permalink
Fix make_ssl_certificate on Python 2
Browse files Browse the repository at this point in the history
Fixes the following exception:

Traceback (most recent call last):

File "/home/travis/build/zoni/err/errbot/backends/base.py", line 520, in
_execute_and_send

for reply in replies:

    File "/home/travis/build/zoni/err/errbot/builtins/webserver.py",
    line 185, in generate_certificate

    make_ssl_certificate(key_path=key_path, cert_path=cert_path)

    File "/home/travis/build/zoni/err/errbot/builtins/webserver.py",
    line 58, in make_ssl_certificate

    cert.sign(pkey, u'sha256')

    File "build/bdist.linux-x86_64/egg/OpenSSL/crypto.py", line 827, in
    sign

    evp_md = _lib.EVP_get_digestbyname(_byte_string(digest))

    TypeError: initializer for ctype 'char *' must be a str or list or
    tuple, not unicode
  • Loading branch information
zoni committed Jul 19, 2014
1 parent c97078d commit e9a1e35
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion errbot/builtins/webserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def make_ssl_certificate(key_path, cert_path):
pkey = crypto.PKey()
pkey.generate_key(crypto.TYPE_RSA, 4096)
cert.set_pubkey(pkey)
cert.sign(pkey, 'sha256')
cert.sign(pkey, 'sha256' if PY3 else b'sha256')

f = open(cert_path, 'w')
f.write(crypto.dump_certificate(crypto.FILETYPE_PEM, cert).decode('utf-8'))
Expand Down

0 comments on commit e9a1e35

Please sign in to comment.