21
HTTPS経由のHttpClientを使用してすべての証明書を信頼する
最近、HttpClientHTTPS に関する質問を投稿しました(ここにあります)。私は少し前進しましたが、新しい問題に出くわしました。私の最後の問題と同様に、私のために機能する例をどこにも見つけることができないようです。基本的に、私はクライアントに証明書を受け入れてもらいたいのですが(私は1つのサーバーしか指していないため)、javax.net.ssl.SSLException: Not trusted server certificate exception. これが私が持っているものです: public void connect() throws A_WHOLE_BUNCH_OF_EXCEPTIONS { HttpPost post = new HttpPost(new URI(PROD_URL)); post.setEntity(new StringEntity(BODY)); KeyStore trusted = KeyStore.getInstance("BKS"); trusted.load(null, "".toCharArray()); SSLSocketFactory sslf = new SSLSocketFactory(trusted); sslf.setHostnameVerifier(SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER); SchemeRegistry schemeRegistry = new SchemeRegistry(); schemeRegistry.register(new Scheme ("https", sslf, 443)); SingleClientConnManager cm = new SingleClientConnManager(post.getParams(), schemeRegistry); …