utils.py 文件源码

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

项目:acmeclient 作者: samjy 项目源码 文件源码
def asn1_generalizedtime_to_dt(timestamp):
    """Convert ASN.1 GENERALIZEDTIME to datetime.

    Useful for deserialization of `OpenSSL.crypto.X509.get_notAfter` and
    `OpenSSL.crypto.X509.get_notAfter` outputs.
    """
    dt = datetime.datetime.strptime(timestamp[:12], '%Y%m%d%H%M%S')
    if timestamp.endswith('Z'):
        tzinfo = pytz.utc
    else:
        sign = -1 if timestamp[-5] == '-' else 1
        tzinfo = pytz.FixedOffset(
            sign * (int(timestamp[-4:-2]) * 60 + int(timestamp[-2:])))
    return tzinfo.localize(dt)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号