{"id":347940,"date":"2023-05-26T15:00:29","date_gmt":"2023-05-26T15:00:29","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=347940"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=347940","title":{"rendered":"<span>\u041a\u0430\u043a \u0441\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c Spring web client \u043f\u043e\u0434 SSL<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 Spring, \u043e\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 rest-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u043f\u043e https. \u041d\u0443\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430 &#8212; spring web client \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c ssl.<\/p>\n<p>\u041d\u0435 \u043d\u0430\u0448\u0435\u043b \u044f\u0432\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u043c\u043d\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f, \u043a\u0430\u043a \u044d\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0443 \u043c\u0435\u043d\u044f. \u0412 \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u043c\u043d\u0435 \u043f\u043e\u043c\u043e\u0433\u043b\u0438 stackoverflow \u0438 \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f SSL (\u0441\u0441\u044b\u043b\u043a\u0438 \u0432 \u043a\u043e\u043d\u0446\u0435).<\/p>\n<h3>\u041d\u0430\u0447\u0438\u043d\u0430\u0435\u043c<\/h3>\n<h4>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f<\/h4>\n<p>\u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0444\u0430\u0439\u043b \u0441\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438 &#8212; application.properties \u0438\u043b\u0438 application.yml. \u0412 \u043d\u0435\u043c \u043c\u044b \u0443\u043a\u0430\u0436\u0435\u043c \u043f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443 \u0441 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430\u043c\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u043a\u043b\u044e\u0447\u0430\u043c\u0438, \u043f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443 \u0441 \u0434\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u043c\u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430\u043c\u0438 (\u043e\u0431\u044b\u0447\u043d\u043e \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u0444\u0430\u0439\u043b) \u0438 \u043f\u0430\u0440\u043e\u043b\u0438.<\/p>\n<pre><code class=\"yaml\">ssl:   trust-store-location: classpath:key.jks   trust-store-password: password   trust-store-type: jks   key-store-location: classpath:key.jks   key-store-password: password   key-store-type: jks   key-password: password<\/code><\/pre>\n<p> \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438. <\/p>\n<pre><code class=\"java\">@Configuration @ConfigurationProperties(\"ssl\") @Data public class SslProperties {     Resource trustStoreLocation;     String trustStorePassword;     String trustStoreType;      Resource keyStoreLocation;     String keyStorePassword;     String keyStoreType;     String keyPassword; }<\/code><\/pre>\n<p> \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0431\u0438\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u201c\u043f\u0440\u0435\u0434-\u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443\u201d \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430: <\/p>\n<pre><code class=\"java\">@Configuration @AllArgsConstructor public class HttpConfig {     private SslProperties props;          @Bean     public WebClientCustomizer configureWebclient() {          return (WebClient.Builder builder) -&gt; {              try {                 SslContext sslContext = createSslContext();                  HttpClient httpClient = HttpClient.create()                     .secure(sslContextSpec -&gt; sslContextSpec.sslContext(sslContext));                  ClientHttpConnector connector = new ReactorClientHttpConnector(httpClient);                 builder.clientConnector(connector);              } catch (KeyStoreException | CertificateException | NoSuchAlgorithmException | IOException | UnrecoverableKeyException e) {                 throw new RuntimeException(e);             }         };      }      private SslContext createSslContext() throws IOException, KeyStoreException, CertificateException, NoSuchAlgorithmException, UnrecoverableKeyException {         \/\/ \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c keyManagerFactory \u0434\u043b\u044f keyStore  KeyStore keyStore = KeyStore.getInstance(props.getKeyStoreType());         keyStore.load(props.getKeyStoreLocation().getInputStream(), props.getKeyStorePassword().toCharArray());         KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());         keyManagerFactory.init(keyStore, props.getKeyPassword().toCharArray());  \/\/ \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c keyManagerFactory \u0434\u043b\u044f trustStore          KeyStore trustStore = KeyStore.getInstance(props.getTrustStoreType());         trustStore.load(props.getTrustStoreLocation().getInputStream(), props.getTrustStorePassword().toCharArray());         TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());         trustManagerFactory.init(trustStore);          return SslContextBuilder.forClient()             .trustManager(trustManagerFactory)             .keyManager(keyManagerFactory)             .build();     }  }<\/code><\/pre>\n<h4>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435<\/h4>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c \u044d\u0442\u043e\u0442 \u0431\u0438\u043d \u0432 \u043a\u043b\u0438\u0435\u043d\u0442\u0435:  <\/p>\n<pre><code class=\"java\">@Service @RequiredArgsConstructor public class Client {      private final WebClient.Builder builder;      public void sendRq() {         builder.build()             .post()   \/\/ \u0434\u0430\u043b\u0435\u0435 \u043b\u043e\u0433\u0438\u043a\u0430 \u043f\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043e\u0442\u0432\u0435\u0442\u0430     } }<\/code><\/pre>\n<h4>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h4>\n<p> \u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u044d\u0442\u0443 \u0448\u0442\u0443\u043a\u0443 \u0441 mockito. \u0421\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043b \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"java\">public class ClientTest {      private Client client; private WebClient.Builder builder;     private WebClient webClientMock;      @BeforeEach     public void setUp() {         webClientMock = mock(WebClient.class);  builder = mock(WebClient.Builder.class);         client = spy(new Client(builder));     }      @Test     public void testFeatureShouldWork() {        when(builder.build()).thenReturn(webClientMock); }  }<\/code><\/pre>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435  <\/h3>\n<p>\u041a\u0430\u0436\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0433\u0438\u0431\u043a\u0430\u044f \u0438 \u0443\u0434\u043e\u0431\u043d\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u043e\u043f\u044b\u0442 \u0438\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u0434\u043b\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f SSL \u0432 spring web client, \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u0435\u0441\u044c, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.  <\/p>\n<p>\u0421\u0441\u044b\u043b\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u043b\u0438 \u043c\u043d\u0435 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/stackoverflow.com\/questions\/45418523\/spring-5-webclient-using-ssl\" rel=\"noopener noreferrer nofollow\">https:\/\/stackoverflow.com\/questions\/45418523\/spring-5-webclient-using-ssl<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/medium.com\/geekculture\/authentication-using-certificates-7e2cfaacd18b\" rel=\"noopener noreferrer nofollow\">https:\/\/medium.com\/geekculture\/authentication-using-certificates-7e2cfaacd18b<\/a><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/737906\/\"> https:\/\/habr.com\/ru\/articles\/737906\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u0443 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0430 Spring, \u043e\u043d\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u0442 rest-\u0437\u0430\u043f\u0440\u043e\u0441\u044b \u0432 \u0434\u0440\u0443\u0433\u043e\u0439 \u0441\u0435\u0440\u0432\u0438\u0441 \u043f\u043e https. \u041d\u0443\u0436\u043d\u043e \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430 &#8212; spring web client \u043a \u0441\u0435\u0440\u0432\u0435\u0440\u0443 \u0441 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c ssl.<\/p>\n<p>\u041d\u0435 \u043d\u0430\u0448\u0435\u043b \u044f\u0432\u043d\u043e \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0435\u0433\u043e \u043c\u043d\u0435 \u0440\u0435\u0448\u0435\u043d\u0438\u044f \u0432 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0445\u043e\u0447\u0443 \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u044c\u0441\u044f, \u043a\u0430\u043a \u044d\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u043e\u0441\u044c \u0443 \u043c\u0435\u043d\u044f. \u0412 \u0440\u0435\u0448\u0435\u043d\u0438\u0438 \u043c\u043d\u0435 \u043f\u043e\u043c\u043e\u0433\u043b\u0438 stackoverflow \u0438 \u043f\u0440\u0438\u043c\u0435\u0440 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f SSL (\u0441\u0441\u044b\u043b\u043a\u0438 \u0432 \u043a\u043e\u043d\u0446\u0435).<\/p>\n<h3>\u041d\u0430\u0447\u0438\u043d\u0430\u0435\u043c<\/h3>\n<h4>\u041a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f<\/h4>\n<p>\u0423 \u043d\u0430\u0441 \u0435\u0441\u0442\u044c \u0444\u0430\u0439\u043b \u0441\u043e \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430\u043c\u0438 &#8212; application.properties \u0438\u043b\u0438 application.yml. \u0412 \u043d\u0435\u043c \u043c\u044b \u0443\u043a\u0430\u0436\u0435\u043c \u043f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443 \u0441 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430\u043c\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u043a\u043b\u044e\u0447\u0430\u043c\u0438, \u043f\u0443\u0442\u044c \u043a \u0444\u0430\u0439\u043b\u0443 \u0441 \u0434\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u043c\u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430\u043c\u0438 (\u043e\u0431\u044b\u0447\u043d\u043e \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u0444\u0430\u0439\u043b) \u0438 \u043f\u0430\u0440\u043e\u043b\u0438.<\/p>\n<pre><code class=\"yaml\">ssl:   trust-store-location: classpath:key.jks   trust-store-password: password   trust-store-type: jks   key-store-location: classpath:key.jks   key-store-password: password   key-store-type: jks   key-password: password<\/code><\/pre>\n<p> \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0439 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u0438. <\/p>\n<pre><code class=\"java\">@Configuration @ConfigurationProperties(\"ssl\") @Data public class SslProperties {     Resource trustStoreLocation;     String trustStorePassword;     String trustStoreType;      Resource keyStoreLocation;     String keyStorePassword;     String keyStoreType;     String keyPassword; }<\/code><\/pre>\n<p> \u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0431\u0438\u043d, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u0442\u044c \u201c\u043f\u0440\u0435\u0434-\u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0443\u201d \u043d\u0430\u0448\u0435\u0433\u043e \u043a\u043b\u0438\u0435\u043d\u0442\u0430: <\/p>\n<pre><code class=\"java\">@Configuration @AllArgsConstructor public class HttpConfig {     private SslProperties props;          @Bean     public WebClientCustomizer configureWebclient() {          return (WebClient.Builder builder) -&gt; {              try {                 SslContext sslContext = createSslContext();                  HttpClient httpClient = HttpClient.create()                     .secure(sslContextSpec -&gt; sslContextSpec.sslContext(sslContext));                  ClientHttpConnector connector = new ReactorClientHttpConnector(httpClient);                 builder.clientConnector(connector);              } catch (KeyStoreException | CertificateException | NoSuchAlgorithmException | IOException | UnrecoverableKeyException e) {                 throw new RuntimeException(e);             }         };      }      private SslContext createSslContext() throws IOException, KeyStoreException, CertificateException, NoSuchAlgorithmException, UnrecoverableKeyException {         \/\/ \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c keyManagerFactory \u0434\u043b\u044f keyStore  KeyStore keyStore = KeyStore.getInstance(props.getKeyStoreType());         keyStore.load(props.getKeyStoreLocation().getInputStream(), props.getKeyStorePassword().toCharArray());         KeyManagerFactory keyManagerFactory = KeyManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());         keyManagerFactory.init(keyStore, props.getKeyPassword().toCharArray());  \/\/ \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c keyManagerFactory \u0434\u043b\u044f trustStore          KeyStore trustStore = KeyStore.getInstance(props.getTrustStoreType());         trustStore.load(props.getTrustStoreLocation().getInputStream(), props.getTrustStorePassword().toCharArray());         TrustManagerFactory trustManagerFactory = TrustManagerFactory.getInstance(TrustManagerFactory.getDefaultAlgorithm());         trustManagerFactory.init(trustStore);          return SslContextBuilder.forClient()             .trustManager(trustManagerFactory)             .keyManager(keyManagerFactory)             .build();     }  }<\/code><\/pre>\n<h4>\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435<\/h4>\n<p>\u0414\u0430\u043b\u0435\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u043c \u044d\u0442\u043e\u0442 \u0431\u0438\u043d \u0432 \u043a\u043b\u0438\u0435\u043d\u0442\u0435:  <\/p>\n<pre><code class=\"java\">@Service @RequiredArgsConstructor public class Client {      private final WebClient.Builder builder;      public void sendRq() {         builder.build()             .post()   \/\/ \u0434\u0430\u043b\u0435\u0435 \u043b\u043e\u0433\u0438\u043a\u0430 \u043f\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0435 \u043e\u0442\u0432\u0435\u0442\u0430     } }<\/code><\/pre>\n<h4>\u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h4>\n<p> \u0422\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043b \u044d\u0442\u0443 \u0448\u0442\u0443\u043a\u0443 \u0441 mockito. \u0421\u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043b \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a:<\/p>\n<pre><code class=\"java\">public class ClientTest {      private Client client; private WebClient.Builder builder;     private WebClient webClientMock;      @BeforeEach     public void setUp() {         webClientMock = mock(WebClient.class);  builder = mock(WebClient.Builder.class);         client = spy(new Client(builder));     }      @Test     public void testFeatureShouldWork() {        when(builder.build()).thenReturn(webClientMock); }  }<\/code><\/pre>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435  <\/h3>\n<p>\u041a\u0430\u0436\u0435\u0442\u0441\u044f, \u0447\u0442\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0430\u0441\u044c \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0433\u0438\u0431\u043a\u0430\u044f \u0438 \u0443\u0434\u043e\u0431\u043d\u0430\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u044f. \u0415\u0441\u043b\u0438 \u0443 \u0432\u0430\u0441 \u0435\u0441\u0442\u044c \u043e\u043f\u044b\u0442 \u0438\u043b\u0438 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u0434\u043b\u044f \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f SSL \u0432 spring web client, \u043f\u043e\u0434\u0435\u043b\u0438\u0442\u0435\u0441\u044c, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430, \u0432 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u044f\u0445.  <\/p>\n<p>\u0421\u0441\u044b\u043b\u043a\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043f\u043e\u043c\u043e\u0433\u043b\u0438 \u043c\u043d\u0435 \u0441\u043e\u0431\u0440\u0430\u0442\u044c \u0442\u0430\u043a\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/stackoverflow.com\/questions\/45418523\/spring-5-webclient-using-ssl\" rel=\"noopener noreferrer nofollow\">https:\/\/stackoverflow.com\/questions\/45418523\/spring-5-webclient-using-ssl<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/medium.com\/geekculture\/authentication-using-certificates-7e2cfaacd18b\" rel=\"noopener noreferrer nofollow\">https:\/\/medium.com\/geekculture\/authentication-using-certificates-7e2cfaacd18b<\/a><\/p>\n<\/li>\n<\/ul>\n<\/div>\n<\/div>\n<p> <!----> <!----><\/div>\n<p> <!----> <!----><br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/articles\/737906\/\"> https:\/\/habr.com\/ru\/articles\/737906\/<\/a><br \/><\/br><\/br><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-347940","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/347940","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=347940"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/347940\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=347940"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=347940"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=347940"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}