def cert_to_string(der): if not der: return '[no certificate]' try: from opcua.crypto import uacrypto except ImportError: return "{0} bytes".format(len(der)) cert = uacrypto.x509_from_der(der) return uacrypto.x509_to_string(cert)