def encode_certificate(result):
 cert_body = '-----BEGIN CERTIFICATE-----\n{0}\n-----END CERTIFICATE-----\n'.format('\n'.join(textwrap.wrap(base64.b64encode(result).decode('utf8'), 64)))
 signed_crt = open('/tmp/signed.crt', 'w')
 signed_crt.write(cert_body)
 signed_crt.close()
 return True

def encode_certificate ( result ) : cert_body = '-----BEGIN CERTIFICATE-----\n{0}\n-----END CERTIFICATE-----\n' . format ( '\n' . join ( textwrap . wrap ( base64 . b64encode ( result ) . decode ( 'utf8' ) , 64 ) ) ) signed_crt = open ( '/tmp/signed.crt' , 'w' ) signed_crt . write ( cert_body ) signed_crt . close ( ) return True
encode cert bytes to pem encoded cert file .