security.py 文件源码

python
阅读 18 收藏 0 点赞 0 评论 0

项目:munki-enrollment-server 作者: gerritdewitt 项目源码 文件源码
def verify_signed_message(given_message,given_encoded_sig,given_cert):
    '''Given strings for the message, its signature, and a certificate object,
        verify the message.  Returns true or false.'''
    # Decode given signature (expected base64 encoding):
    try:
        decoded_sig = base64.b64decode(given_encoded_sig)
    except:
        common.logging_error("Could not interpret encoded signature.")
        return False
    # Verify the signature:
    try:
        # OpenSSL is funny.  A successful crypto.verify() returns a None object!
        crypto.verify(given_cert,decoded_sig,given_message,config_client_pki.CSR_SIGNING_HASH_ALGORITHM)
        return True
    except crypto.Error:
        common.logging_error("Message fails verification.")
        return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号