📄 sslsocket.java
字号:
/*
* SSL-Explorer
*
* Copyright (C) 2003-2006 3SP LTD. All Rights Reserved
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
package com.maverick.ssl;
/* DEBUG */ import org.apache.commons.logging.*;
import java.io.ByteArrayOutputStream;
import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.EOFException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.net.UnknownHostException;
import java.net.*;
import com.maverick.ssl.https.HttpsURLStreamHandlerFactory;
public class SSLSocket
extends Socket {
SSLTransport transport = new SSLTransport();
/* DEBUG */ Log log = LogFactory.getLog(SSLSocket.class);
public SSLSocket(String host, int port) throws IOException,
UnknownHostException,
SSLException {
this(host, port, false);
}
public SSLSocket(String host,
int port,
boolean delayHandshake) throws IOException,
UnknownHostException,
SSLException {
super(host, port);
if(!delayHandshake)
startHandshake(null);
}
public InputStream getInputStream() throws IOException {
return transport.getInputStream();
}
public OutputStream getOutputStream() throws IOException {
return transport.getOutputStream();
}
protected void startHandshake(SSLContext context) throws IOException, SSLException {
transport.initialize(super.getInputStream(), super.getOutputStream(), context);
}
protected InputStream getRawInputStream() throws IOException {
return super.getInputStream();
}
protected OutputStream getRawOutputStream() throws IOException {
return super.getOutputStream();
}
public static void main(String[] args) {
try {
HttpsURLStreamHandlerFactory.addHTTPSSupport();
URL url = new URL("https://3sp.com");
URLConnection con = url.openConnection();
con.setDoInput(true);
con.setDoOutput(false);
con.setAllowUserInteraction(false);
con.setRequestProperty("Accept", "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, application/x-shockwave-flash, */*");
con.setRequestProperty("Accept-Encoding","gzip, deflate");
con.setRequestProperty("Accept-Language","en-gb");
con.setRequestProperty("Connection","Keep-Alive");
con.setRequestProperty("User-Agent","Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)");
con.connect();
InputStream in = con.getInputStream();
int read;
while ( (read = in.read()) > -1) {
System.out.write(read);
}
}
catch (SSLIOException ex) {
ex.getRealException().printStackTrace();
}
catch (IOException ex) {
ex.printStackTrace();
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -