小编wrg*_*grs的帖子

如何验证python中的X509证书,包括CRL检查?

我正在尝试使用python验证X509证书.特别是当我这样做时,我需要检查CRL.

现在,您可以使用m2crypto执行此操作,但我找不到与openssl的-crl_check或-crl_check_all相对应的选项.

或者,我可以使用管道并直接调用openssl:

p1 = Popen(["openssl", "verify", "-CApath", capath, "-crl_check_all"], 
           stdin = PIPE, stdout = PIPE, stderr = PIPE)

message, error = p1.communicate(certificate)
exit_code = p1.returncode
Run Code Online (Sandbox Code Playgroud)

但是,似乎openssl verify总是返回一个退出代码0,所以我不得不以某种方式比较字符串来判断验证是否成功,我不想这样做.

我错过了一些简单的东西吗?

谢谢.

python openssl m2crypto

5
推荐指数
1
解决办法
2803
查看次数

在python日期中处理几个月

我有一个函数,它在提供日期时间之前的月份开始:

def get_start_of_previous_month(dt):
    '''
    Return the datetime corresponding to the start of the month
    before the provided datetime.
    '''
    target_month = (dt.month - 1)
    if target_month == 0:
        target_month = 12
    year_delta = (dt.month - 2) / 12
    target_year = dt.year + year_delta

    midnight = datetime.time.min
    target_date = datetime.date(target_year, target_month, 1)
    start_of_target_month = datetime.datetime.combine(target_date, midnight)
    return start_of_target_month
Run Code Online (Sandbox Code Playgroud)

但是,它似乎非常复杂.谁能建议更简单的方法?我正在使用python 2.4.

python datetime python-2.4

3
推荐指数
1
解决办法
704
查看次数

R重复功能不处理不兼容的问题

我试图用来duplicated查找数据帧中仅基于两列重复的行.

当我将任何内容传递给incomparables参数时,我得到了错误

dups = duplicated(data, incomparables="Age")
...
argument 'incomparables != FALSE' is not used (yet)
Run Code Online (Sandbox Code Playgroud)

我无法弄清楚这一点.

这个问题似乎有类似的问题,没有回应.

毫无疑问,有一种不同的方式来做同样的事情,这也很好知道,因为我是R的初学者.

r duplicate-removal

3
推荐指数
1
解决办法
1763
查看次数

R中的单向哈希函数

R中是否有可重复的单向哈希函数?我会hashlib在Python中使用:

hashlib.sha224("This is my input").hexdigest()
Run Code Online (Sandbox Code Playgroud)

hash r

1
推荐指数
1
解决办法
959
查看次数

标签 统计

python ×2

r ×2

datetime ×1

duplicate-removal ×1

hash ×1

m2crypto ×1

openssl ×1

python-2.4 ×1