public class ConnectURLHTTPS
{
private String page;
private BufferedWriter bw;
ConnectURLHTTPS(String url)
{
Security.addProvider(new com.sun.net.ssl.internal.ssl.Provider());
System.setProperty("java.protocol.handler.pkgs","com.sun.net.ssl.internal.www.protocol");
try
{
page = "";
String line = "",
proxy = "myproxy",
port = "80",
authentication = "myusername:mypwd";
URL server = new URL(url);
System.out.println("url destino");
// Connect to the server using an SSL socket
SSLSocketFactory factory = (SSLSocketFactory) SSLSocketFactory.getDefault();
SSLSocket socket = (SSLSocket) factory.createSocket(proxy,Integer.parseInt(port));
System.out.println("socket criado");
//Socket socket = new Socket(proxy,Integer.parseInt(port));
Writer writer = new OutputStreamWriter(socket.getOutputStream(),"US-ASCII");
writer.write("GET " + server.toExternalForm() + " HTTP/1.1
");
writer.write("Host: " + server.getHost() + ":80
");
writer.write("User-Agent: Java HTTPS Client");
writer.write("Proxy-Authorization: Basic "+ new sun.misc.BASE64Encoder().encode(authentication.getBytes())+ "
");
writer.flush();
BufferedReader reader = new BufferedReader(new InputStreamReader(socket.getInputStream(),"US-ASCII"));
line = reader.readLine();
while (line != null)
{
page += line + "
";
line = reader.readLine();
}
System.out.println(page);
reader.close();
writer.close();
socket.close();
}
catch(Exception e)
{
System.out.println(e);
}
}
public static void main(String args[])
{
ConnectURLHTTPS cn = new ConnectURLHTTPS(https://www.sitequalquer.com.br);
}
o erro q esta retornando eh esse:
Exception in thread "main" javax.net.ssl.SSLHandshakeException: Remote host clos ed connection during handshake at com.sun.net.ssl.internal.ssl.SSLSocketImpl.a(DashoA6275) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.j(DashoA6275) at com.sun.net.ssl.internal.ssl.SSLSocketImpl.startHandshake(DashoA6275)at SSLSocketClient.main(SSLSocketClient.java:48 )
Caused by: java.io.EOFException: SSL peer shut down incorrectly
at com.sun.net.ssl.internal.ssl.InputRecord.read(DashoA6275)
... 4 more
se alguem souber resolver me ajude por favor
:wink: