gpt4 book ai didi

scala - 使用 Scala 调度库禁用 SSL

转载 作者:太空宇宙 更新时间:2023-11-03 12:47:51 25 4
gpt4 key购买 nike

我目前正在将我们所有的 Rest 测试移动到 CI 服务器,并且注意到所有测试都由于 SSL 握手而失败,现在我已经通过 TrustManager 和我们的 Java 测试套件成功地禁用了它,但是我不确定如何使用 Scala 调度库来做到这一点,并且还没有找到许多适用于这种情况的示例。

val JSONstr = "{samplekey:samplevalue}"
val response:String = Http(url("https://www.host.com/path/to/post")
<< (checkInJSONstr, "application/json") as_str)

如预期的那样发生了以下异常:

javax.net.ssl.SSLPeerUnverifiedException: peer not authenticated at     com.sun.net.ssl.internal.ssl.SSLSessionImpl.getPeerCertificates(SSLSessionImpl.java:352)
...

有没有一种方法可以在语法上干净利落地使用调度库忽略 SSL?

最佳答案

import dispatch._
val http = new Http with HttpsLeniency
val response:String = http(url("https://www.host.com/path/to/post")
<< (checkInJSONstr, "application/json") as_str)

关于scala - 使用 Scala 调度库禁用 SSL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12586971/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com