如何解决quickstart示例中的javax.net.ssl.sslexception?

ercv8c1e  于 2021-08-25  发布在  Java
关注(0)|答案(2)|浏览(450)

这个问题在这里已经有了答案

空手道dsl:获取连接超时错误(1个答案)
四天前关门。
由于某些原因,我无法运行quickstart示例。我的假设是,它与公司代理有关。以下是我的步骤:
使用maven原型创建新项目(如文档中所述)。
运行测试(首先不进行任何调整),并获得以下结果:

[pool-1-thread-1] ERROR com.intuit.karate - java.net.UnknownHostException: jsonplaceholder.typicode.com, http call failed after 648 milliseconds for url: https://jsonplaceholder.typicode.com/users
[pool-1-thread-2] ERROR com.intuit.karate - java.net.UnknownHostException: jsonplaceholder.typicode.com, http call failed after 564 milliseconds for url: https://jsonplaceholder.typicode.com/users
[pool-1-thread-1] ERROR com.intuit.karate - classpath:examples/users/users.feature:9
When method get
http call failed after 648 milliseconds for url: https://jsonplaceholder.typicode.com/users
classpath:examples/users/users.feature:9
[pool-1-thread-2] ERROR com.intuit.karate - classpath:examples/users/users.feature:36
When method post
http call failed after 564 milliseconds for url: https://jsonplaceholder.typicode.com/users
classpath:examples/users/users.feature:36
---------------------------------------------------------
feature: classpath:examples/users/users.feature
scenarios:  2 | passed:  0 | failed:  2 | time: 1.3194
---------------------------------------------------------

对以下各项进行调整: karate-config.js :

function fn() {
  // ...
  var config = {
    // ...
    proxy: {uri: 'https://xx.xx.xx.xxx:1234', username: 'my_username', password: 'my_password'},
  }
  // ...
  karate.configure('ssl', true);
  karate.configure('proxy', config.proxy);
  return config;
}

再次运行测试并获得以下结果:

[pool-1-thread-1] ERROR com.intuit.karate - javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?, http call failed after 278 milliseconds for url: https://jsonplaceholder.typicode.com/users
[pool-1-thread-2] ERROR com.intuit.karate - javax.net.ssl.SSLException: Unrecognized SSL message, plaintext connection?, http call failed after 100 milliseconds for url: https://jsonplaceholder.typicode.com/users
[pool-1-thread-1] ERROR com.intuit.karate - classpath:examples/users/users.feature:9
When method get
http call failed after 278 milliseconds for url: https://jsonplaceholder.typicode.com/users
classpath:examples/users/users.feature:9
[pool-1-thread-2] ERROR com.intuit.karate - classpath:examples/users/users.feature:36
When method post
http call failed after 100 milliseconds for url: https://jsonplaceholder.typicode.com/users
classpath:examples/users/users.feature:36
---------------------------------------------------------
feature: classpath:examples/users/users.feature
scenarios:  2 | passed:  0 | failed:  2 | time: 0.5533
---------------------------------------------------------

添加 httpclient ,如本答案所述。不幸的是,结果仍然与上面第4点相同。
你知道怎么解决这个问题吗?

yb3bgrhw

yb3bgrhw1#

将公司代理中的证书合并到默认信任库中,并将其提供给您的程序。您的公司代理可能使用了自签名证书,该证书不在信任库中,因此无法用于通过https进行连接

0qx6xfy6

0qx6xfy62#

试试其他例子:

Feature: simple requests

Scenario: simple post

* url 'https://httpbin.org'
* param foo = 'bar'
* path 'anything'
* request { foo: 'bar' }
* method post
* match response contains { json: { foo: 'bar' } }

相关问题