java.security.NoSuchAlgorithmException: TLS SSLContext not available
来源:互联网 发布:比利时保拉王后知乎 编辑:程序博客网 时间:2024/05/16 14:43
问题描述
使用httpclient的时候运行时如下代码报错
CloseableHttpClient httpclient = HttpClients.createDefault();
异常信息如下
Exception in thread "main" org.apache.http.ssl.SSLInitializationException: TLS SSLContext not available at org.apache.http.ssl.SSLContexts.createDefault(SSLContexts.java:58) at org.apache.http.impl.client.HttpClientBuilder.build(HttpClientBuilder.java:966) at org.apache.http.impl.client.HttpClients.createDefault(HttpClients.java:58) at yan.javatips.closure.HttpTest2.main(HttpTest2.java:26) Caused by: java.security.NoSuchAlgorithmException: TLS SSLContext not available at sun.security.jca.GetInstance.getInstance(GetInstance.java:159) at javax.net.ssl.SSLContext.getInstance(SSLContext.java:156) at org.apache.http.ssl.SSLContexts.createDefault(SSLContexts.java:54) ... 3 more
可是同样的程序在windows平台下没有问题,对应的jar文件在linux平台运行却报错。
解决办法
最初以为是jdk版本不一致,以及linux平台openssl版本过低等原因,中间还遇到了依赖编译、classpath路径设置等问题。主要由于是windows平台下eclipse编写开发,而非在linux平台下直接开发,有些问题可能就没有注意到,比如所需的包是否存在,但是linux下java编译也是通过的。
而后找了源码,发现对应sslcontext是在jsse.jar中,看了看windows目录jre对应文件夹下有此包,再去看linux的jre文件夹下,发现是jsse.pack。使用如下命令转换即可:
root@XXXX:/usr/java/jdk1.8.0_101# cd jre/libroot@XXXX:/usr/java/jdk1.8.0_101/jre/lib# unpack200 jsse.pack jsse.jarroot@XXXX:/usr/java/jdk1.8.0_101/jre/lib#
再次运行,一切ok!
0 1
- java.security.NoSuchAlgorithmException: TLS SSLContext not available
- java.security.NoSuchAlgorithmException: SSLContext SSL implementation not found
- java.security.NoSuchAlgorithmException: Algorithm DH not available
- java.security.NoSuchAlgorithmException: AES KeyGenerator not available
- [测试]java.security.NoSuchAlgorithmException HmacSHA256 not available.
- java.security.NoSuchAlgorithmException: Algorithm HmacSHA1 not available
- Caused by: java.security.NoSuchAlgorithmException: SunTlsRsaPremasterSecret KeyGenerator not availab
- 解决A true SSLContext object is not available
- pip: InsecurePlatformWarning: A true SSLContext object is not available
- pip install InsecurePlatformWarning: A true SSLContext object is not available.
- 【已解决】 java.security.KeyStoreException: java.security.NoSuchAlgorithmException
- java.security.NoSuchAlgorithmException: No such algorithm: RSA/ECB/PKCS1Padding 问题解决
- java.security.NoSuchAlgorithmException: Cannot find any provider supporting DES 解决方案
- java SSLContext
- java SSLContext
- java SSLContext
- gnome-calculator TLS support is not available
- pip安装模块警告InsecurePlatformWarning: A true SSLContext object is not available.
- 工程实践中最常用的10大数据结构与算法讲解(0)
- iOS 自动布局注意事项
- 二十三.优化整个项目界面
- ajax 多文件上传
- HDU 4352 XHXJ's LIS(数位DP+状压)
- java.security.NoSuchAlgorithmException: TLS SSLContext not available
- 【python爬虫】爬取知乎收藏夹内所有问题名称地址保存至Mysql
- 【机房收费】上下机
- poj 2367 Genealogical tree ( 拓扑排序--二维数组)
- (5) Java GC算法及种类
- java 简单贪吃蛇
- listview的局部刷新
- 51nod:1002 数塔取数问题
- ubuntu下如何控制风扇速度?