小编Ash*_*aya的帖子

在python中读取证书(.crt)和密钥(.key)文件

因此,我使用 JIRA-Python 模块连接到我公司的 JIRA 实例,它要求我为此传递证书和密钥。但是,使用 OpenSSL 模块,我无法读取本地证书和密钥来将其传递给请求。

阅读代码如下

import OpenSSL.crypto 
c = open('/Users/mpadakan/.certs/mpadakan-blr-mpsot-20160704.crt').read()
cert = OpenSSL.crypto.dump_certificate(OpenSSL.crypto.FILETYPE_PEM, c)
Run Code Online (Sandbox Code Playgroud)

我得到的错误是

Traceback (most recent call last):
File "flaskApp.py", line 19, in <module>
cert = OpenSSL.crypto.dump_certificate(OpenSSL.crypto.FILETYPE_PEM, c)
TypeError: must be X509, not str
Run Code Online (Sandbox Code Playgroud)

有人可以告诉我如何将本地 .crt 和 .key 文件读入 x509 对象吗?

python pyopenssl python-jira

7
推荐指数
1
解决办法
2万
查看次数

docker-compose psql无法连接到服务器

我看了github MD文件的瓶装水,使用docker使用它,我遇到了关于postgresql的问题

如果我跑, docker-compose run --rm postgres psql我得到错误

/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. This prevents urllib3 from configuring SSL appropriately and may cause certain SSL connections to fail. For more information, see https://urllib3.readthedocs.org/en/latest/security.html#insecureplatformwarning.
  InsecurePlatformWarning
/usr/local/lib/python2.7/dist-packages/requests/packages/urllib3/util/ssl_.py:90: InsecurePlatformWarning: A true SSLContext object is not available. …
Run Code Online (Sandbox Code Playgroud)

python postgresql psql docker docker-compose

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

从 postgres 中选择列到 json 中

我有一个这样的餐桌员工

name     value 
'e1'     'rahul'
'e2'     'priya'
'e3'     'abhijit'
Run Code Online (Sandbox Code Playgroud)

我需要从两列中提取json,结果是这样的

{'e1':'rahul','e2':'priya','e3':'abhijit'}
Run Code Online (Sandbox Code Playgroud)

我尝试了以下查询,结果如下

select row_to_json((name,value)) from employee 

O/P

{'f1':'e1','f2':'rahul'}
{'f2':'e1','f2':'priya'}
{'f3':'e1','f2':'abhijit'}
Run Code Online (Sandbox Code Playgroud)

我不想要那里的 f1 和 f2 名称,请指教!

postgresql json

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