File tree 1 file changed +5
-3
lines changed
1 file changed +5
-3
lines changed Original file line number Diff line number Diff line change 78
78
79
79
.. code-block :: python
80
80
81
- import ssl
81
+ import ssl
82
82
83
- class SSLMixin :
83
+ class SSLMixin :
84
84
'''
85
85
Mixin class that adds support for SSL to existing servers based
86
86
on the socketserver module.
253
253
例如,web浏览器保存了主要的认证机构的证书,并使用它来为每一个HTTPS连接确认证书的合法性。
254
254
对本小节示例而言,只是为了测试,我们可以创建自签名的证书,下面是主要步骤:
255
255
256
-
256
+ ::
257
257
bash % openssl req -new -x509 -days 365 -nodes -out server_cert.pem \
258
258
-keyout server_key.pem
259
259
Generating a 1024 bit RSA private key
282
282
在创建证书的时候,各个值的设定可以是任意的,但是”Common Name“的值通常要包含服务器的DNS主机名。
283
283
如果你只是在本机测试,那么就使用”localhost“,否则使用服务器的域名。
284
284
285
+ ::
285
286
-----BEGIN RSA PRIVATE KEY-----
286
287
MIICXQIBAAKBgQCZrCNLoEyAKF+f9UNcFaz5Osa6jf7qkbUl8si5xQrY3ZYC7juu
287
288
nL1dZLn/VbEFIITaUOgvBtPv1qUWTJGwga62VSG1oFE0ODIx3g2Nh4sRf+rySsx2
300
301
301
302
服务器证书文件server_cert.pem内容类似下面这样:
302
303
304
+ ::
303
305
-----BEGIN CERTIFICATE-----
304
306
MIIC+DCCAmGgAwIBAgIJAPMd+vi45js3MA0GCSqGSIb3DQEBBQUAMFwxCzAJBgNV
305
307
BAYTAlVTMREwDwYDVQQIEwhJbGxpbm9pczEQMA4GA1UEBxMHQ2hpY2FnbzEUMBIG
You can’t perform that action at this time.
0 commit comments