ssl socket communicatoin to an epp server

落花浮王杯 提交于 2019-12-25 16:43:59

问题


tI'm implementing a client in java that comunicates to an EPP server via TCP and SSL.

I nead to send some xml-s to the server via SSL an read some xml responses. I dont have a client certificate and I dont nead one. I just nead to be able to send requests to that server and read responses. Im quite new to this topic.

My code is this :

SSLSocketFactory sslsocketfactory = (SSLSocketFactory) SSLSocketFactory.getDefault();
SSLSocket sslsocket = (SSLSocket) sslsocketfactory.createSocket("server.epp.si", 65000);              

DataOutputStream outToServerSSL = new DataOutputStream(sslsocket.getOutputStream());
BufferedReader inFromServerSSL = new BufferedReader(new InputStreamReader(sslsocket.getInputStream()));

outToServerSSL.write(somXML.getBytes());

inFromServerSSL.readLine();

It doesn't depens what string I put in the xml I get always the same greating xml response back.

Now I'm wondering if even the SSL hanshake went OK. How is possible to check it the connection is successfuly established and that the reciever is ready to receive data. So that I exlude the connection problem itself.


回答1:


Standard EPP is defined to always send the greeting on connection to the server, so in your code above you are writing your command to the server but the input buffer will already have the greeting on, so this is what you would get back when reading the response.

The correct flow is as follows

  1. Connect to EPP Server via SSLSocket
  2. Read the greeting from the input stream
  3. Send the login command
  4. Read the login response
  5. Send your EPP command
  6. Read the Response to your commands
  7. Repeat steps 5&6 until you have done everything necessary
  8. Send the logout command
  9. Read the logout response
  10. Close the socket



回答2:


You can debug the communication when running your project with

java -Djavax.net.debug=all.

You can see the whole handshake, it should end with

*** Finished verify_data:... ****

and then some plain and encrypted data.



来源:https://stackoverflow.com/questions/22013287/ssl-socket-communicatoin-to-an-epp-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!