JupyterHub openssl self signed cert "Error: error:0906D06C:PEM routines:PEM_read_bio:no start line"

JupyterHub openssl self signed cert "Error: error:0906D06C:PEM routines:PEM_read_bio:no start line"

尝试使用自签名 OPENSSL key/cert 对在 AWS 实例上的 JupyterHub 上进行配置。我尝试了几种 openssl 配置,但仍然出现同样的错误。

jupyterhub
[I 2016-10-04 03:38:24.090 JupyterHub app:622] Loading cookie_secret from           /home/ubuntu/jupyterhub_cookie_secret
[W 2016-10-04 03:38:24.123 JupyterHub app:304] 
    Generating CONFIGPROXY_AUTH_TOKEN. Restarting the Hub will require     restarting the proxy.
    Set CONFIGPROXY_AUTH_TOKEN env or JupyterHub.proxy_auth_token config to avoid this message.

[W 2016-10-04 03:38:24.127 JupyterHub app:757] No admin users, admin interface will be unavailable.
[W 2016-10-04 03:38:24.127 JupyterHub app:758] Add any administrative users to `c.Authenticator.admin_users` in config.
[I 2016-10-04 03:38:24.127 JupyterHub app:785] Not using whitelist. Any authenticated user will be allowed.
[I 2016-10-04 03:38:24.139 JupyterHub app:1231] Hub API listening on http://127.0.0.1:8081/hub/
[I 2016-10-04 03:38:24.143 JupyterHub app:968] Starting proxy @ http://*:8000/

crypto.js:128
      c.context.setKey(options.key);
            ^
Error: error:0906D06C:PEM routines:PEM_read_bio:no start line
    at Object.exports.createCredentials (crypto.js:128:17)
    at Server (tls.js:1176:28)
    at new Server (https.js:35:14)
    at Object.exports.createServer (https.js:54:10)
    at new ConfigurableProxy (/usr/lib/node_modules/configurable-http-    proxy/lib/configproxy.js:174:35)
    at Object.<anonymous> (/usr/lib/node_modules/configurable-http-proxy/bin/configurable-http-proxy:189:13)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
[C 2016-10-04 03:38:25.158 JupyterHub app:1237] Failed to start proxy
    Traceback (most recent call last):
      File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/jupyterhub/app.py", line 1235, in start
    yield self.start_proxy()
      File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/jupyterhub/app.py", line 989, in start_proxy
    _check()
      File "/home/ubuntu/anaconda3/lib/python3.5/site-packages/jupyterhub/app.py", line 985, in _check
        raise e
    RuntimeError: Proxy failed to start with exit code 8

使用此命令生成当前对

openssl req -new -x509 -days 365 -utf8 -out mycert.pem -keyout mykey.pem

验证它实际上是 PEM 格式

openssl x509 -in mycert.pem -text -noout
Certificate:
    Data:
        Version: 3 (0x2)
        Serial Number:
            ec:16:a1:7d:64:6b:90:42
    Signature Algorithm: sha256WithRSAEncryption
        Issuer: C=SG, ST=SG, L=Singapore, O=GoldenCompass
        Validity
            Not Before: Oct  4 02:58:55 2016 GMT
            Not After : Oct  4 02:58:55 2017 GMT
        Subject: C=SG, ST=SG, L=Singapore, O=GoldenCompass
        Subject Public Key Info:
            Public Key Algorithm: rsaEncryption
                Public-Key: (2048 bit)
<snippet>

jupyterhub_config.py

<snippet>
## Path to SSL certificate file for the public facing interface of the proxy
#  
#  Use with ssl_key
c.JupyterHub.ssl_cert = '/home/ubuntu/mykey.pem'

## Path to SSL key file for the public facing interface of the proxy
#  
#  Use with ssl_cert
c.JupyterHub.ssl_key = '/home/ubuntu/mycert.pem'

<snippet>

您的配置中证书和密钥被颠倒了:

你有这个:

c.JupyterHub.ssl_cert = '/home/ubuntu/mykey.pem'
c.JupyterHub.ssl_key = '/home/ubuntu/mycert.pem'

但你应该有这个:

c.JupyterHub.ssl_cert = '/home/ubuntu/mycert.pem'
c.JupyterHub.ssl_key = '/home/ubuntu/mykey.pem'