openssl转换成时间戳接口 C语言
时间: 2023-10-14 18:05:29 浏览: 55
可以使用timegm函数将openssl转换成时间戳,该函数在time.h头文件中声明。可以按照以下方式使用:
#include <time.h>
#include <openssl/ssl.h>
ssl = SSL_new(ctx);
SSL_get_peer_certificate(ssl);
cert = SSL_get_peer_certificate(ssl);
tm = X509_get_notBefore(cert);
time_t notBefore_time = timegm(gmtime(&tm));
注意,通过使用gmtime函数将时间生成为UTC标准时间,然后使用timegm函数将其转换为时间戳。
相关问题
openssl转换成时间戳接口
您可以使用以下代码将openssl格式的时间转换为时间戳:
```python
import datetime
openssl_formatted_time = "Apr 8 16:01:30 2021 GMT"
dt = datetime.datetime.strptime(openssl_formatted_time, '%b %d %H:%M:%S %Y %Z')
timestamp = int(dt.timestamp())
print(timestamp)
```
这段代码把openssl格式的时间字符串(如上述范例)转换为Python中的datetime对象,然后使用该对象的timestamp()方法将其转换为时间戳。
openssl转换成时间戳
您好!我可以帮您回答问题。要将OpenSSL时间戳转换为普通时间戳,可以使用以下命令:
```
$ openssl x509 -enddate -noout -in certificate.pem | cut -d= -f 2- | xargs -0 date +%s -d
```
其中,certificate.pem 是所需转换的证书。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)