Я использую Spring Boot 3.4.1, JDK 23, MySQL 9. Меня очень радует новая функция RestClient в новой версии Spring Framework. Я могу без каких-либо проблем выполнить взаимный TLS с RestTemplate, теперь я хочу испытать совершенно новую функцию RestClient в контексте SSLBundle (или, если это невозможно, используйте SSLContext).
Файл application.yml
Я использую Spring Boot 3.4.1, JDK 23, MySQL 9. Меня очень радует новая функция RestClient в новой версии Spring Framework. Я могу без каких-либо проблем выполнить взаимный TLS с RestTemplate, теперь я хочу испытать совершенно новую функцию RestClient в контексте SSLBundle (или, если это невозможно, используйте SSLContext). Файл application.yml [code]server: port: 8001 ssl: bundle: bar client-auth: NEED enabled: true spring: datasource: driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://localhost:3306/fuu001?useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true username: ggAABB password: XXxxYY ssl: bundle: jks: foo: keystore: location: C:\\ssl\\server-identity.p12 password: quynhPucca type: PKCS12 truststore: location: C:\\ssl\\server-truststore.p12 password: XXggMMinhThuRangXinh type: PKCS12 reload-on-update: true bar: keystore: location: C:\\ssl\\client-identity.p12 password: ThucAnhNongTinh type: PKCS12 truststore: location: C:\\ssl\\client-truststore.p12 password: hoaMauDon2025 type: PKCS12 reload-on-update: true jpa: hibernate: ddl-auto: create-drop properties: hibernate: format_sql: true show-sql: true # security: # user: # name: user # password: user [/code] Файл CallFooService.java содержит содержимое [code]package com.example;
RestClient customClient = RestClient.builder() .requestFactory(new HttpComponentsClientHttpRequestFactory()) // I want inject SSLBundle or SSL Context at here or something else. .messageConverters(converters -> converters.add(null)) .baseUrl("https://example.com") .defaultUriVariables(Map.of("variable", "foo")) .defaultHeader("My-Header", "Foo") .defaultCookie("My-Cookie", "Bar") .requestInterceptor(null) .requestInitializer(null) // I want inject SSLBundle or SSL Context at here or something else. .build(); }
}
[/code] Spring Boot 3.4.1: как настроить SSLBundle для работы с RestClient? Связано: [list][*]https://spring.io/blog/2023/07/13/new-in-spring-6-1-restclient