我正在尝试使用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,所以我不得不以某种方式比较字符串来判断验证是否成功,我不想这样做.
我错过了一些简单的东西吗?
谢谢.
我有一个函数,它在提供日期时间之前的月份开始:
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.
我试图用来duplicated
查找数据帧中仅基于两列重复的行.
当我将任何内容传递给incomparables
参数时,我得到了错误
dups = duplicated(data, incomparables="Age")
...
argument 'incomparables != FALSE' is not used (yet)
Run Code Online (Sandbox Code Playgroud)
我无法弄清楚这一点.
这个问题似乎有类似的问题,没有回应.
毫无疑问,有一种不同的方式来做同样的事情,这也很好知道,因为我是R的初学者.
R中是否有可重复的单向哈希函数?我会hashlib
在Python中使用:
hashlib.sha224("This is my input").hexdigest()
Run Code Online (Sandbox Code Playgroud)