如何使用Java(套接字)将SPOP3服务器连接/远程登录? [英] How to connect/telnet to SPOP3 server using java (Sockets)?

查看:206
本文介绍了如何使用Java(套接字)将SPOP3服务器连接/远程登录?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于POP3,可以使用端口110上的套接字通过telnet连接,但是如果实现了SPOP3,该怎么做. 使用普通的telnet,可以很容易地完成

In case of POP3 it is possible to connect via telnet using sockets over port 110, But how to do it , if SPOP3 is implemented. With normal telnet it can be done quite easily with

Socket pop3Socket = new Socket(host.com, 110);

仅供参考: 为了连接到SPOP3,我们在linux/unix中使用

FYI: For connecting to SPOP3 we use in linux/unix

 openssl s_client -connect servername.com:995

推荐答案

您将需要使用SSLSocket类.可以在以下位置找到示例: http://www.herongyang. com/JDK/SSL-Socket-Client-Example-SslSocketClient.html .

You'll need to use the SSLSocket class. An example can be found at: http://www.herongyang.com/JDK/SSL-Socket-Client-Example-SslSocketClient.html.

基本上,您将执行以下操作:

Basically, you'll do something like:

SSLSocketFactory f = (SSLSocketFactory) SSLSocketFactory.getDefault();
SSLSocket c =        (SSLSocket) f.createSocket("localhost", 8888);

如果端点具有自签名证书,那么您有两个选择:

If the endpoint has a self signed certificate then you have two options:

  1. 将此自签名证书添加到您的本地密钥库中.该URL提供了很好的概述: http://www.chrissearle.org/blog/technical/adding_self_signed_https_certificate_java_keystore
  2. 创建一个不验证服务器证书的TrustManager: http://www.howardism .org/Technical/Java/SelfSignedCerts.html
  1. Add this self-signed cert to your local keystore. This URL gives a good overview: http://www.chrissearle.org/blog/technical/adding_self_signed_https_certificates_java_keystore
  2. Create a TrustManager that does not validate the server's certificate: http://www.howardism.org/Technical/Java/SelfSignedCerts.html

选项1更安全.

这篇关于如何使用Java(套接字)将SPOP3服务器连接/远程登录?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆