Revision 0f9294f7 lib/utils.py
b/lib/utils.py | ||
---|---|---|
2835 | 2835 |
return rows[-lines:] |
2836 | 2836 |
|
2837 | 2837 |
|
2838 |
def FormatTimestampWithTZ(secs): |
|
2839 |
"""Formats a Unix timestamp with the local timezone. |
|
2840 |
|
|
2841 |
@type secs: number |
|
2842 |
@param secs: Seconds since the Epoch (1970-01-01 00:00:00 UTC) |
|
2843 |
|
|
2844 |
""" |
|
2845 |
return time.strftime("%F %T %Z", time.localtime(secs)) |
|
2846 |
|
|
2847 |
|
|
2848 | 2838 |
def _ParseAsn1Generalizedtime(value): |
2849 | 2839 |
"""Parses an ASN1 GENERALIZEDTIME timestamp as used by pyOpenSSL. |
2850 | 2840 |
|
2851 | 2841 |
@type value: string |
2852 | 2842 |
@param value: ASN1 GENERALIZEDTIME timestamp |
2843 |
@return: Seconds since the Epoch (1970-01-01 00:00:00 UTC) |
|
2853 | 2844 |
|
2854 | 2845 |
""" |
2855 | 2846 |
m = _ASN1_TIME_REGEX.match(value) |
... | ... | |
2931 | 2922 |
|
2932 | 2923 |
if not_before is not None and not_after is not None: |
2933 | 2924 |
msg += (" (valid from %s to %s)" % |
2934 |
(FormatTimestampWithTZ(not_before), |
|
2935 |
FormatTimestampWithTZ(not_after))) |
|
2925 |
(FormatTime(not_before), FormatTime(not_after))) |
|
2936 | 2926 |
elif not_before is not None: |
2937 |
msg += " (valid from %s)" % FormatTimestampWithTZ(not_before)
|
|
2927 |
msg += " (valid from %s)" % FormatTime(not_before) |
|
2938 | 2928 |
elif not_after is not None: |
2939 |
msg += " (valid until %s)" % FormatTimestampWithTZ(not_after)
|
|
2929 |
msg += " (valid until %s)" % FormatTime(not_after) |
|
2940 | 2930 |
|
2941 | 2931 |
return (CERT_ERROR, msg) |
2942 | 2932 |
|
2943 | 2933 |
elif not_before is not None and not_before > now: |
2944 | 2934 |
return (CERT_WARNING, |
2945 | 2935 |
"Certificate not yet valid (valid from %s)" % |
2946 |
FormatTimestampWithTZ(not_before))
|
|
2936 |
FormatTime(not_before)) |
|
2947 | 2937 |
|
2948 | 2938 |
elif not_after is not None: |
2949 | 2939 |
remaining_days = int((not_after - now) / (24 * 3600)) |
Also available in: Unified diff