python - 使用 Python 拉取 Mimecast 日志

标签 python logging mta

我希望有人经历过这个,并希望有一个有效的 Python 脚本。我一直在尝试从 Mimecast 中提取 MTA 日志。到目前为止,我已经尝试过 来自以下网站的代码:

https://www.mimecast.com/tech-connect/documentation/endpoint-reference/logs-and-statistics/get-siem-logs/

https://github.com/JoshuaSmeda/mimecast_log_collector

https://github.com/bsdkid/mimecast-api-class/blob/master/get-TTP.py

我得到的错误是

SSLError: HTTPSConnectionPool(host='api.mimecast.com', port=443): Max retries exceeded with url: /api/login/discover-authentication (Caused by SSLError(SSLError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:645)'),))

我还拥有所有必要的凭据,例如用户(帐户)、密码、app_id、app_key、access_key 和 Secret_key。不幸的是,没有什么对我有用。

非常感谢任何帮助。

谢谢

最佳答案

您的环境中可能发生了某种 SSL 检查。

您是否尝试过在另一个可能没有透明代理过滤互联网流量的测试实例上进行测试。

您还可以尝试对 API 请求使用 SSL 验证参数(设置为 false)来忽略证书验证问题。

参数:

verify=False

基于 https://github.com/JoshuaSmeda/mimecast_log_collector 的示例:

try:
  r = requests.post(url='https://api.mimecast.com/api/login/discover-authentication', data=json.dumps(post_body), headers=headers, verify=False)

如果它适用于发现 - 则将验证参数添加到每个帖子中。请记住这样做的风险,因为您将面临 MITM 攻击。 HTTP 存在风险。

有关请求的文档可以在此处找到:

https://buildmedia.readthedocs.org/media/pdf/requests/latest/requests.pdf

希望这有帮助。

关于python - 使用 Python 拉取 Mimecast 日志,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56858075/

相关文章:

python - 让 matplotlib 渲染用鼠标点击的点。

php - 电子邮件中 ​​.eml 文件的 MIME 类型是什么

logging - 使用ssl时如何获取haproxy详细的http日志?

python 日志记录 : Different formatters for the same log file

c# - 在STAThread和MTAThread之间切换以及内存泄漏

python - 如何修复此Python代码中的属性错误:'Series'对象没有属性 'reshape'?

python - 查找两个数组的非交叉值

python - Django:限制模型数据

android - 记录策略