首页 > 其他分享 >resttemplate绕过https认证

resttemplate绕过https认证

时间:2023-04-11 15:26:33浏览次数:33  
标签:acceptingTrustStrategy HttpComponentsClientHttpRequestFactory resttemplate facto

public class RestTemplateConfig {
public static HttpComponentsClientHttpRequestFactory generateHttpRequestFactory()
throws NoSuchAlgorithmException, KeyManagementException, KeyStoreException
{
TrustStrategy acceptingTrustStrategy = (x509Certificates, authType) -> true;
SSLContext sslContext = SSLContexts.custom().loadTrustMaterial(null, acceptingTrustStrategy).build();
SSLConnectionSocketFactory connectionSocketFactory = new SSLConnectionSocketFactory(sslContext, new NoopHostnameVerifier());

HttpClientBuilder httpClientBuilder = HttpClients.custom();
httpClientBuilder.setSSLSocketFactory(connectionSocketFactory);
CloseableHttpClient httpClient = httpClientBuilder.build();
HttpComponentsClientHttpRequestFactory factory = new HttpComponentsClientHttpRequestFactory();
factory.setHttpClient(httpClient);
return factory;
}
}

标签:acceptingTrustStrategy,HttpComponentsClientHttpRequestFactory,resttemplate,facto
From: https://www.cnblogs.com/niuniu0108/p/17306339.html

相关文章

  • [网络]应用层协议:HTTP / HTTPS
    1HTTP/HTTPS概述2HTTP/22.1HTTP/2辉煌不在?虽然HTTP/2标准在2015年5月就以RFC7540正式发表了,并且多数浏览器在2015年底就支持了。但是,真正被广泛使用起来要到2018年左右,但是也是在2018年,11月IETF给出了官方批准,认可HTTP-over-QUIC成为HTTP/3。2018年的时候,我写过一篇......
  • java.lang.NoSuchMethodException: com.innovation.web.BuyServlet.$%7Bid%7D(javax.s
    问题描述我在html页面写了get到删除某条记录的url路径里去,然后一直显示这个错误,也到不了相应的后台方法里面去,就很离谱欸家人们!问题解决听从友友的建议,将之前的/deleteCarts/${id}改成了之前用过的那种样式,也就是/deleteCarts?id=${id},然后就成功跳转到那个后台servlet里面啦!......
  • HTTP/HTTPS/HTTP2
    HTTP协议图文简述--HTTP/HTTPS/HTTP2 01、准备1.1、先了解下网络模型/TCPHTTP 连接是建立在 TCP*协议之上的,其数据传输功能是由TCP完成的,那TCP又是什么呢?TCP 是一个单纯用来建立通信连接,并传输数据的基础协议,属于网络模型中的的传输层。OSI模型(OpenSystemInterc......
  • SpringSecurity之WebSecurity和HttpSecurity
    SpringSecurity启动过程中有两个重要的类。分别是WebSecurity和HttpSecurity。 看看WebSecurity的定义:publicfinalclassWebSecurityextendsAbstractConfiguredSecurityBuilder<Filter,WebSecurity>implementsSecurityBuilder<Filter>,ApplicationContextAware,Servl......
  • 23.04.06_为博客设置https
    title:为博客设置https协议categories: -博客优化date:2023-04-06url_dir:Blog_optimizationurl_name:setting_https博客优化内容http协议的网站总是显示不安全,为了开启小绿锁,在这里准备部署https协议。我的博客是hexo架构,部署在阿里云上的。在阿里云首页中选择产......
  • 20230408---pg_dump: [归档 (db)] 与数据库 "xxx" 联接失败: 致命错误: 对用户"postg
    pg_dump:[归档(db)]与数据库"wpfc"联接失败:致命错误:  对用户"postgres"的对等认证失败 不修改pg_hba.conf的情况下进入postgres用户执行 cd/homemkdirpostgreschown-Rpostgres:postgres/home/postgres/chmod760/home/postgres/supostgrespg_dump-U......
  • 用Abp实现双因素认证(Two-Factor Authentication, 2FA)登录(一):认证模块
    @目录原理用户验证码校验模块双因素认证模块改写登录在之前的博文用Abp实现短信验证码免密登录(一):短信校验模块一文中,我们实现了用户验证码校验模块,今天来拓展这个模块,使Abp用户系统支持双因素认证(Two-FactorAuthentication)功能。双因素认证(Two-FactorAuthentication,简称2FA......
  • 【中文乱码】HttpServletResponse PrintWriter中文乱码解决方法
    HttpServletResponse使用PrintWriter输出中文的时候,如果不设置流的编码就会产生乱码,PrintWriter直接输出的字符流首先使用"response.setCharacterEncoding(charset)"设置字符以什么样的编码输出到浏览器,如果不设置则默认是ISO-8859-1,这个是不支持中文的。解决方法publicvoid......
  • TOTAL:AWS 认证解决方案架构师助理 (SAA-C03)
    TOTAL:AWS认证解决方案架构师助理(SAA-C03)超值:通过AWSCertifiedSolutionsArchitect–AssociateSAA-C03考试+AWSEssentials和2次免费练习考试课程英文名:TOTALAWSCertifiedSolutionsArchitectAssociate(SAA-C03)此视频教程共15.9GB,中英双语字幕,画质清晰无......
  • https请求ssl认证失败
    问题描述:程序需使用第三方进行开票,第三方服务提供https的post请求接口,并提供基于pfx证书的安全认证。原始服务基于.netcore3.1,dockerfile基础镜像是mcr.microsoft.com/dotnet/core/aspnet:3.1-bionic,版本迭代时进行了sdk升级为.net6,基础镜像是mcr.microsoft.com/dotnet/aspnet:6.......