简体   繁体   English

HTTP Get - Python 与 Spring Rest 模板

[英]HTTP Get - Python vs Spring Rest Template

I am consuming a rest service using the code below -我正在使用以下代码使用休息服务 -

r = requests.get(url=uril)

The above code returns the error below -上面的代码返回以下错误 -

(Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self signed certificate in certificate chain (_ssl.c:1045)'))) (由 SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] 证书验证失败:证书链中的自签名证书 (_ssl.c:1045)') 引起))

However when I consume the same endpoint using Spring RestTemplate , I am able to successfully consume the service without passing any certificates.但是,当我使用 Spring RestTemplate 使用相同的端点时,我能够在不传递任何证书的情况下成功使用该服务。

Can you please let me know why there is a difference in behavior of these clients?您能否让我知道为什么这些客户的行为有所不同?

Spring implies Java and Java comes equipped with an up to date trust store out of the box, which is then used by Spring. Spring 意味着 Java 并且 Java 配备了一个开箱即用的最新信任存储,然后由 Spring 使用。 Maybe Python does not include such functionality out of the box, which means you have to do some extra preconfiguration of the client you use to perform the request.也许 Python 不包含这种开箱即用的功能,这意味着您必须对用于执行请求的客户端进行一些额外的预配置。 See documentation on http.client.HTTPSConnection.请参阅有关 http.client.HTTPSConnection 的文档。

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

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