在Windows中生成SSL密钥和证书

时间:2016-06-22 05:54:45

标签: windows ssl kibana

根据https://www.elastic.co/guide/en/shield/current/kibana.html, 我需要设置

import requests

url = 'http://someurl.com/404-page.html'
myHeaders = {'User-agent': 'myUserAgent'}

s = requests.Session()

try:
    page = s.get(url, headers=myHeaders)
    #if page.status_code != requests.codes.ok:
    #     page.raise_for_status()
except requests.ConnectionError:
    print ("DNS problem or refused to connect")
    # Or Do something with it
except requests.HTTPError:
    print ("Some HTTP response error")
    #Or Do something with it
except requests.Timeout:
    print ("Error loading...too long")
    #Or Do something with it, perhaps retry
except requests.TooManyRedirects:
    print ("Too many redirect")
    #Or Do something with it
except requests.RequestException as e:
    print (e.message)
    #Or Do something with it
else:
    print ("nothing happen")
    #Do something if no exception

s.close()

在哪里可以找到Windows环境中密钥和证书的路径?或者我该如何制作一个并找到关键和路径?

1 个答案:

答案 0 :(得分:4)

您需要生成自己的自签名证书或向证书颁发机构申请证书。在此之后,您将获得.key(证书的私钥)和.crt(证书的公共部分)

要创建自签名证书,请点击此链接How to create a self-signed certificate with openssl?

你需要openssl

openssl genrsa -des3 -out server.key 2048
openssl rsa -in server.key -out server.key
openssl req -sha256 -new -key server.key -out server.csr -subj "/CN=localhost"
openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt

将“localhost”替换为您的域名。逐个运行命令,因为openssl将提示您生成证书的相同值

如果您需要受信任的证书,请向letsencrypt.org等受信任的机构申请