1

SSL接続で独自の証明書を検証するには、独自のCAが必要です。私はこれを試していますが、うまくいきません:

            try {
                AssetManager assetManager = getApplicationContext().getAssets();
                InputStream inStrm = assetManager.open("cacert-devel.der");

                Intent intent = KeyChain.createInstallIntent();
                CertificateFactory cf = CertificateFactory.getInstance("X.509");
                X509Certificate x509 = (X509Certificate) cf.generateCertificate(inStrm);
                inStrm.close();
                intent.putExtra(KeyChain.EXTRA_CERTIFICATE, x509.getEncoded());
                intent.putExtra(KeyChain.EXTRA_NAME,"PCA");
                startActivity(intent);
            } catch (CertificateException e1) {
                // TODO Auto-generated catch block
            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

CA がインストールされていることをテストするにはどうすればよいですか? この CA のサーバーへの SSL の後、以下を返します。

            DefaultHttpClient httpclient = new DefaultHttpClient();
            HttpGet httpget = new HttpGet();
            HttpResponse response = null;
            httpget.setURI(new URI("https://url...");
            response = httpclient.execute(httpget);
            StatusLine status = response.getStatusLine();
            int statuscode = status.getStatusCode();
            if (statuscode != 200){
                Log.e("GET", "Status"   + statuscode);
            }else{
                Log.e("GET","Status:"  + statuscode);
            }

IO 例外javax.net.ssl.SSLPeerUnverifiedException: ピア証明書がありません

なにか提案を?

4

0 に答える 0