F-5885: verify peer hostname for non-loopback hosts in Client example
parent
83d5e683ea
commit
e6b9302f20
|
|
@ -446,6 +446,11 @@ public class Client {
|
|||
sslCtx.setRsaDecCb(rsaDec);
|
||||
}
|
||||
|
||||
/* Verify the peer hostname for non-loopback hosts. The example
|
||||
* certs carry no loopback name. */
|
||||
boolean checkDomain = (verifyPeer != 0) &&
|
||||
!InetAddress.getByName(host).isLoopbackAddress();
|
||||
|
||||
if (benchmark != 0) {
|
||||
int times = benchmark;
|
||||
int i = 0;
|
||||
|
|
@ -466,6 +471,15 @@ public class Client {
|
|||
ssl = new WolfSSLSession(sslCtx);
|
||||
ssl.setFd(sock);
|
||||
|
||||
if (checkDomain) {
|
||||
ret = ssl.checkDomainName(host);
|
||||
if (ret != WolfSSL.SSL_SUCCESS) {
|
||||
System.out.println(
|
||||
"failed to set domain name check!");
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
ret = ssl.connect();
|
||||
err = ssl.getError(ret);
|
||||
|
|
@ -648,6 +662,14 @@ public class Client {
|
|||
ssl.setRsaDecCtx(rsaDecCtx);
|
||||
}
|
||||
|
||||
if (checkDomain) {
|
||||
ret = ssl.checkDomainName(host);
|
||||
if (ret != WolfSSL.SSL_SUCCESS) {
|
||||
System.out.println("failed to set domain name check!");
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* call wolfSSL_connect */
|
||||
do {
|
||||
ret = ssl.connect();
|
||||
|
|
@ -822,6 +844,15 @@ public class Client {
|
|||
/* restore saved WOLFSSL_SESSION */
|
||||
ssl.setSession(session);
|
||||
|
||||
if (checkDomain) {
|
||||
ret = ssl.checkDomainName(host);
|
||||
if (ret != WolfSSL.SSL_SUCCESS) {
|
||||
System.out.println(
|
||||
"failed to set domain name check!");
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/* call wolfSSL_connect */
|
||||
do {
|
||||
ret = ssl.connect();
|
||||
|
|
|
|||
Loading…
Reference in New Issue