URL: https://github.com/freeipa/freeipa/pull/1057
Author: flo-renaud
 Title: #1057: py3: fix ipa cert-request --database ...
Action: opened

PR body:
"""
Fix bytes vs str issues in ipa cert-request

https://pagure.io/freeipa/issue/7148
"""

To pull the PR as Git branch:
git remote add ghfreeipa https://github.com/freeipa/freeipa
git fetch ghfreeipa pull/1057/head:pr1057
git checkout pr1057
From 54e3e91db77cf2298786770f5da76e9d299b0695 Mon Sep 17 00:00:00 2001
From: Florence Blanc-Renaud <f...@redhat.com>
Date: Mon, 11 Sep 2017 18:24:22 +0200
Subject: [PATCH] py3: fix ipa cert-request --database ...

Fix bytes vs str issues in ipa cert-request

https://pagure.io/freeipa/issue/7148
---
 ipaclient/csrgen.py       | 6 +++---
 ipaclient/plugins/cert.py | 2 +-
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/ipaclient/csrgen.py b/ipaclient/csrgen.py
index 3f3ea1cde6..bcc9aab3c9 100644
--- a/ipaclient/csrgen.py
+++ b/ipaclient/csrgen.py
@@ -407,11 +407,11 @@ def __init__(self, key_filename, password_filename):
         self.password_filename = password_filename
 
     def key(self):
-        with open(self.key_filename, 'r') as key_file:
+        with open(self.key_filename, 'rb') as key_file:
             key_bytes = key_file.read()
         password = None
         if self.password_filename is not None:
-            with open(self.password_filename, 'r') as password_file:
+            with open(self.password_filename, 'rb') as password_file:
                 password = password_file.read().strip()
 
         key = load_pem_private_key(key_bytes, password, default_backend())
@@ -454,7 +454,7 @@ def __init__(self, database, password_filename):
         self.nickname = base64.b32encode(os.urandom(40))
 
     def get_subject_public_key_info(self):
-        temp_cn = base64.b32encode(os.urandom(40))
+        temp_cn = base64.b32encode(os.urandom(40)).decode('ascii')
 
         password_args = []
         if self.password_filename is not None:
diff --git a/ipaclient/plugins/cert.py b/ipaclient/plugins/cert.py
index d5daaf3a15..1365ad32aa 100644
--- a/ipaclient/plugins/cert.py
+++ b/ipaclient/plugins/cert.py
@@ -120,7 +120,7 @@ def forward(self, csr=None, **options):
                     message=u"One of 'database' or 'private_key' is required")
 
             pubkey_info = adaptor.get_subject_public_key_info()
-            pubkey_info_b64 = base64.b64encode(pubkey_info)
+            pubkey_info_b64 = base64.b64encode(pubkey_info).decode('ascii')
 
             # If csr_profile_id is passed, that takes precedence.
             # Otherwise, use profile_id. If neither are passed, the default
_______________________________________________
FreeIPA-devel mailing list -- freeipa-devel@lists.fedorahosted.org
To unsubscribe send an email to freeipa-devel-le...@lists.fedorahosted.org

Reply via email to