1

任何人都知道如何使用 Netty Socket SSL Server 连接 Android Client SSL?

这是服务器代码。( SecureChatSslContextFactory )

    KeyStore ks = KeyStore.getInstance("PKCS12");
    FileInputStream fin = new FileInputStream("C:\\StartSSL\\pkcsserver.p12"); //secret");

    // Set up key manager factory to use our key store
    KeyManagerFactory kmf = KeyManagerFactory.getInstance(algorithm);
    kmf.init(ks, keyPass);

    // Initialize the SSLContext to work with our key managers.
    serverContext = SSLContext.getInstance(PROTOCOL);
    serverContext.init(kmf.getKeyManagers(), null, null);

这是Android客户端代码:

        KeyStore ksTrust = KeyStore.getInstance("PKCS12");
        ksTrust.load(context.getResources().openRawResource(R.raw.pkcsserver), passphrase);
        TrustManagerFactory tmf = TrustManagerFactory.getInstance(KeyManagerFactory.getDefaultAlgorithm());
        tmf.init(ksTrust);

        //get context
        SSLContext sslContext = SSLContext.getInstance("TLS");

        //init context
        sslContext.init(null, tmf.getTrustManagers(), new SecureRandom());

请告诉我哪里错了。

4

0 回答 0