禁用 SSL 连接的主机名检查?

发布于 2024-09-18 13:07:30 字数 857 浏览 6 评论 0原文

我正在使用 clojure-http 进行以下 POST:

(clojure-http.resourcefully/post "https://android.apis.google.com/c2dm/send"
  {"Authorization" (str "GoogleLogin auth=" auth-token)}
  {"registration_id" registration-id
   "data.msg" "blah"
   "collapse_key" "blah"})

并收到此异常:

java.security.cert.CertificateException: No subject alternative DNS name matching android.apis.google.com found.
[Thrown class javax.net.ssl.SSLHandshakeException]

由于某些奇怪的原因,大约 10% 的时间我没有收到异常并且请求通过。

我认为这是 Java 主机名检查 SSL 连接的问题*,所以我的问题是,如何从 Clojure 禁用它? (或者从安全角度来说这是一个坏主意?)

谢谢, 魏

*从这篇文章和其他类似文章中推断出:http://www.jroller.com/hasant /entry/no_subject_alternative_names_matching

I'm using clojure-http to make the following POST:

(clojure-http.resourcefully/post "https://android.apis.google.com/c2dm/send"
  {"Authorization" (str "GoogleLogin auth=" auth-token)}
  {"registration_id" registration-id
   "data.msg" "blah"
   "collapse_key" "blah"})

And getting this exception:

java.security.cert.CertificateException: No subject alternative DNS name matching android.apis.google.com found.
[Thrown class javax.net.ssl.SSLHandshakeException]

For some weird reason, about 10% of the time I don't get the exception and the request goes through.

I believe it's an issue with Java's host name checking on SSL connections*, so my question is, how do I disable that from Clojure? (or is that a bad idea security-wise?)

Thanks,
Wei

*deduced from this post and others like it: http://www.jroller.com/hasant/entry/no_subject_alternative_names_matching

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

錯遇了你 2024-09-25 13:07:30

这不是你的代码的问题,而是android网站的问题。

在现代浏览器中打开此链接 - https://android.apis.google.com/。您将看到 SSL 证书属于 *.google.com,但您正在访问 *.apis.google.com 下的域。您可能应该在 Android 论坛上搜索此问题的解决方案。

禁用主机名检查是一个坏主意,您将面临中间人攻击。如果你不太关心安全性,你不妨使用http,它比禁用主机名检查更容易。

Its not a problem with your code, its a problem with android's website.

Open this link in a modern browser- https://android.apis.google.com/. You will see that the SSL certificate belongs to *.google.com, but you are visiting a domain under *.apis.google.com. You should probably search on Android forums for a solution to this problem.

Its a bad idea to disable host name checking, you are opening up yourself to man-in-the-middle attacks. If you don't really care about security, you might as well use http, its easier than disabling host name checks.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文