首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >禁用WebTestClient的TLS证书检查

禁用WebTestClient的TLS证书检查
EN

Stack Overflow用户
提问于 2017-10-19 13:56:34
回答 1查看 1.7K关注 0票数 3

我在集成测试中使用Spring WebFlux WebTestClient。我使用WebTestClient.bindToServer()创建客户端。测试服务器使用HTTPS服务资源。我有以下代码:

代码语言:javascript
复制
WebTestClient webTestClient = WebTestClient.bindToServer()
    .baseUrl("https://secured.example.com")
    .build();
webTestClient.get().uri("/index.html")
    .exchange()
    .expectStatus().isOk();

在测试中不需要使用有效的证书。如何配置WebTestClient以信任所有证书?

我可以配置WebClient来信任每个人。但是WebTestClient更适合编写测试。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-11-08 16:19:53

您可以使用可以提供给WebTestClient的自定义WebTestClient来配置它。

代码语言:javascript
复制
// create a custom connector and customize TLS configuration there.
ReactorClientHttpConnector connector = new ReactorClientHttpConnector(options -> options...);
WebTestClient client = WebTestClient.bindToServer(connector);

这一点最近在SPR-16168中得到了修正。

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/46831656

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档