简体   繁体   English

如何让 PyC​​harm 接受我的自签名 SSL 证书?

[英]How to let PyCharm accept my self-signed SSL certificate?

I need PyCharm (2019.1, on macOS High Sierra) to accept my self-signed SSL certificate when connecting to a remote secure Jupyter notebook server.在连接到远程安全 Jupyter 笔记本服务器时,我需要 PyCharm(2019.1,在 macOS High Sierra 上)来接受我的自签名 SSL 证书。 ( https://jupyter-notebook.readthedocs.io/en/latest/public_server.html ) ( https://jupyter-notebook.readthedocs.io/en/latest/public_server.html )

I've tried我试过了

  1. Add the certificate file to Preferences/Tools/Server Certificates.将证书文件添加到首选项/工具/服务器证书。

  2. keytool -import -alias cacerts -file jupytercert.pem (I think that will probably allow the JRE that PyCharm relies on to accept the certificate) keytool -import -alias cacerts -file jupytercert.pem (我认为这可能会允许 PyCharm 依赖的 JRE 接受证书)

Neither resolves the problem.两者都不能解决问题。 When attempting a connection, an error prompts:尝试连接时,错误提示:

PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: 
unable to find valid certification path to requested target.

PS The certificate was generated using: openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout jupyterkey.key -out jupytercert.pem PS证书是使用生成的: openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout jupyterkey.key -out jupytercert.pem

I had the same issue on Ubuntu, using the snap installation method.我在 Ubuntu 上遇到了同样的问题,使用 snap 安装方法。

I was able to fix the issue by first adding the custom certificate to my local java keystore with:我能够通过首先将自定义证书添加到我的本地 java 密钥库来解决这个问题:

sudo keytool -import -trustcacerts -keystore /etc/ssl/certs/java/cacerts \
   -storepass changeit -noprompt -file path/to/my/certificate.crt  -alias my_cert_alias

Then I had to override the keystore used by pycharm in the snap using my local keystore.然后我不得不使用我的本地密钥库在 snap 包中覆盖 pycharm 使用的密钥库。 I could do that with a mount, as suggested in https://askubuntu.com/a/1036611/143257 :我可以通过安装来做到这一点,如https://askubuntu.com/a/1036611/143257 中所建议的:

sudo mount --bind -o nodev,ro /etc/ssl/certs/java/cacerts \
    /snap/pycharm-professional/136/jre64/lib/security/cacerts

May there be a bug on Pycharm 2019, where the certificates for jupyter notebook access are not checked through the "Preferences/Tools/Server Certificates" filter? Pycharm 2019 是否存在错误,未通过“首选项/工具/服务器证书”过滤器检查 jupyter notebook 访问的证书?

My suggestion to you would be to find where does pycharm store its keystore on macOS and add the custom certificate there.我对您的建议是找到 pycharm 在 macOS 上存储其密钥库的位置并在那里添加自定义证书。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM