Merge pull request #111 from cconlon/sslSocketNullHost
Support null host with createSocket(Socket, String, int, boolean)pull/112/head
commit
f515a3e60c
|
@ -333,7 +333,6 @@ public class WolfSSLSocket extends SSLSocket {
|
||||||
this.params = params.copy();
|
this.params = params.copy();
|
||||||
this.socket = s;
|
this.socket = s;
|
||||||
this.autoClose = autoClose;
|
this.autoClose = autoClose;
|
||||||
this.address = new InetSocketAddress(host, port);
|
|
||||||
|
|
||||||
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
|
WolfSSLDebug.log(getClass(), WolfSSLDebug.INFO,
|
||||||
"creating new WolfSSLSocket(clientMode: " +
|
"creating new WolfSSLSocket(clientMode: " +
|
||||||
|
|
|
@ -528,7 +528,8 @@ public class WolfSSLServerSocketTest {
|
||||||
/* Expected. Different versions of wolfSSL can display
|
/* Expected. Different versions of wolfSSL can display
|
||||||
* varying error strings. Check for either here. */
|
* varying error strings. Check for either here. */
|
||||||
if (!e.toString().contains("ASN no signer") &&
|
if (!e.toString().contains("ASN no signer") &&
|
||||||
!e.toString().contains("certificate verify failed")) {
|
!e.toString().contains("certificate verify failed") &&
|
||||||
|
!e.toString().contains("ASN self-signed certificate error")) {
|
||||||
System.out.println("\t\t... failed");
|
System.out.println("\t\t... failed");
|
||||||
fail();
|
fail();
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,6 +89,7 @@ import com.wolfssl.WolfSSLException;
|
||||||
public void testGetSetEnabledProtocols();
|
public void testGetSetEnabledProtocols();
|
||||||
public void testClientServerThreaded();
|
public void testClientServerThreaded();
|
||||||
public void testPreConsumedSocket();
|
public void testPreConsumedSocket();
|
||||||
|
public void testCreateSocketNullHost();
|
||||||
public void testEnableSessionCreation();
|
public void testEnableSessionCreation();
|
||||||
public void testSetUseClientMode();
|
public void testSetUseClientMode();
|
||||||
public void testGetSSLParameters();
|
public void testGetSSLParameters();
|
||||||
|
@ -530,6 +531,36 @@ public class WolfSSLSocketTest {
|
||||||
System.out.println("\t... passed");
|
System.out.println("\t... passed");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCreateSocketNullHost() throws Exception {
|
||||||
|
|
||||||
|
System.out.print("\tcreateSocket(null host)");
|
||||||
|
|
||||||
|
/* create new CTX */
|
||||||
|
this.ctx = tf.createSSLContext("TLS", ctxProvider);
|
||||||
|
|
||||||
|
/* create new ServerSocket first to get ephemeral port */
|
||||||
|
ServerSocket ss = new ServerSocket(0);
|
||||||
|
|
||||||
|
/* create new Socket, connect() to server */
|
||||||
|
Socket cs = new Socket();
|
||||||
|
cs.connect(new InetSocketAddress(ss.getLocalPort()));
|
||||||
|
|
||||||
|
/* accept client connection, normal java.net.Socket */
|
||||||
|
final Socket socket = ss.accept();
|
||||||
|
|
||||||
|
/* Try to convert client Socket to SSLSocket, with null hostname.
|
||||||
|
* This should not throw any Exceptions, null host is ok. */
|
||||||
|
SSLSocket ssc = (SSLSocket)ctx.getSocketFactory().createSocket(
|
||||||
|
cs, null, cs.getPort(), false);
|
||||||
|
|
||||||
|
ssc.close();
|
||||||
|
cs.close();
|
||||||
|
socket.close();
|
||||||
|
ss.close();
|
||||||
|
|
||||||
|
System.out.println("\t\t... passed");
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEnableSessionCreation() throws Exception {
|
public void testEnableSessionCreation() throws Exception {
|
||||||
|
|
Loading…
Reference in New Issue