1

我正在编写一个应用程序来从 XMPP 服务器获取证书。但在那之后,我无法弄清楚要求它的方法。这是我的Java代码:

            Socket connection =new Socket("talk.google.com", 5222);
        DataInputStream input = new DataInputStream(connection.getInputStream());
        BufferedReader d = new BufferedReader(new InputStreamReader(input,"UTF-8"));
        BufferedWriter to_server = new BufferedWriter(
                new OutputStreamWriter(connection.getOutputStream(),"UTF-8")
                );
        String responseLine="";
        to_server.write(initiate_conn);
        to_server.flush();
        int in;
        while(!(responseLine.contains("</stream:features>")))
        {
            responseLine += (char)d.read();   
        }
        System.out.println("Server: " + responseLine);
        to_server.write(start_tls);
        to_server.flush();
        responseLine="";
        while(!(responseLine.contains("<proceed xmlns=\"urn:ietf:params:xml:ns:xmpp-tls\"/>")))
            responseLine += (char)d.read();  
        System.out.println("Server: " + responseLine);

我得到的结果如下:

Server: stream:stream from="110.47.18.148" id="2D416C8DE320C481" version="1.0" x
mlns:stream="http://etherx.jabber.org/streams" xmlns="jabber:client" stream:fea
tures starttls xmlns="urn:ietf:params:xml:ns:xmpp-tls" required  starttls m
echanisms xmlns="urn:ietf:params:xml:ns:xmpp-sasl"  mechanism X-OAUTH2  mechanis
m mechanism X-GOOGLE-TOKEN mechanism mechanisms stream:features
Server:  proceed xmlns="urn:ietf:params:xml:ns:xmpp-tls"

有谁知道这些之后如何获得证书?太感谢了!

4

0 回答 0