diff --git a/plugins/module_utils/ansible_freeipa_module.py b/plugins/module_utils/ansible_freeipa_module.py
index 8154a12c33050552afb17cdba781da9ae20ae43a..1ea64346ce9f8b0240e203de7244da75cf071d6e 100644
--- a/plugins/module_utils/ansible_freeipa_module.py
+++ b/plugins/module_utils/ansible_freeipa_module.py
@@ -268,7 +268,7 @@ def encode_certificate(cert):
     Encode a certificate using base64 with also taking FreeIPA and Python
     versions into account
     """
-    if isinstance(cert, str) or isinstance(cert, unicode):
+    if isinstance(cert, (str, unicode, bytes)):
         encoded = base64.b64encode(cert)
     else:
         encoded = base64.b64encode(cert.public_bytes(Encoding.DER))