Skip to content

Commit

Permalink
wiztools#50 wiztools#48 Now in the UI we have the option of ignoring …
Browse files Browse the repository at this point in the history
…all certificate errors (instead of just self-signed certificate).
  • Loading branch information
subwiz committed May 5, 2016
1 parent 8cf3aea commit 4a3ca8b
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ else if(part instanceof ReqEntityFilePart) {
null:
sslReq.getKeyStore().getKeyStore();

final TrustStrategy trustStrategy = sslReq.isTrustSelfSignedCert()
final TrustStrategy trustStrategy = sslReq.isTrustAllCerts()
? new TrustAllTrustStrategy(): null;

SSLContext ctx = new SSLContextBuilder()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
public interface SSLReq extends Serializable {

SSLHostnameVerifier getHostNameVerifier();
boolean isTrustSelfSignedCert();
boolean isTrustAllCerts();

SSLKeyStore getKeyStore();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ public class SSLReqBean implements SSLReq {
// Default to strict!
private SSLHostnameVerifier hostNameVerifier = SSLHostnameVerifier.STRICT;

private boolean trustSelfSignedCert = false;
private boolean trustAllCerts = false;

public void setHostNameVerifier(SSLHostnameVerifier sslHostNameVerifier) {
this.hostNameVerifier = sslHostNameVerifier;
}

public void setTrustSelfSignedCert(boolean sslTrustSelfSignedCert) {
this.trustSelfSignedCert = sslTrustSelfSignedCert;
public void setTrustAllCerts(boolean sslTrustSelfSignedCert) {
this.trustAllCerts = sslTrustSelfSignedCert;
}

public void setKeyStore(SSLKeyStore sslKeyStore) {
Expand All @@ -48,8 +48,8 @@ public SSLKeyStore getTrustStore() {
}

@Override
public boolean isTrustSelfSignedCert() {
return trustSelfSignedCert;
public boolean isTrustAllCerts() {
return trustAllCerts;
}

@Override
Expand All @@ -58,7 +58,7 @@ public int hashCode() {
hash = 29 * hash + Objects.hashCode(this.trustStore);
hash = 29 * hash + Objects.hashCode(this.keyStore);
hash = 29 * hash + Objects.hashCode(this.hostNameVerifier);
hash = 29 * hash + (this.trustSelfSignedCert ? 1 : 0);
hash = 29 * hash + (this.trustAllCerts ? 1 : 0);
return hash;
}

Expand All @@ -80,7 +80,7 @@ public boolean equals(Object obj) {
if (this.hostNameVerifier != other.hostNameVerifier) {
return false;
}
if (this.trustSelfSignedCert != other.trustSelfSignedCert) {
if (this.trustAllCerts != other.trustAllCerts) {
return false;
}
return true;
Expand All @@ -90,7 +90,7 @@ public boolean equals(Object obj) {
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("@SSL[");
sb.append("trustSelfSignedCert=").append(trustSelfSignedCert).append(", ");
sb.append("trustSelfSignedCert=").append(trustAllCerts).append(", ");
sb.append("hostNameVerifier=").append(hostNameVerifier).append(", ");
sb.append("trustStore=").append(trustStore).append(", ");
sb.append("keyStore=").append(keyStore).append(", ");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ private XmlSslUtil() {}
static Element getSslReq(SSLReq req) {
Element eSsl = new Element("ssl");

if(req.isTrustSelfSignedCert()) {
Element e = new Element("trust-self-signed-cert");
if(req.isTrustAllCerts()) {
Element e = new Element("ignore-cert-errs");
eSsl.appendChild(e);
}

Expand Down Expand Up @@ -62,8 +62,9 @@ static SSLReq getSslReq(Element eSsl) {
Element e = eChildren.get(i);
final String name = e.getLocalName();
if(null != name) switch (name) {
case "trust-self-signed-cert":
out.setTrustSelfSignedCert(true);
case "trust-self-signed-cert": // backward-compatibility...
case "ignore-cert-errs":
out.setTrustAllCerts(true);
break;
case "hostname-verifier":
out.setHostNameVerifier(SSLHostnameVerifier.valueOf(e.getValue()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ public void testSsl() throws Exception {
expResult.setHttpVersion(HTTPVersion.HTTP_1_1);
expResult.setFollowRedirect(true);
SSLReqBean ssl = new SSLReqBean();
ssl.setTrustSelfSignedCert(true);
ssl.setTrustAllCerts(true);
ssl.setHostNameVerifier(SSLHostnameVerifier.ALLOW_ALL);
expResult.setSslReq(ssl);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class ReqSSLPanelImpl extends JPanel implements ReqSSLPanel {

// SSL - general
private final JCheckBox jcb_disable_hostname_verifier = new JCheckBox("Disable hostname verification? ");
private final JCheckBox jcb_ssl_trust_self_signed_cert = new JCheckBox("Trust self-signed certificate? ");
private final JCheckBox jcb_ssl_trust_self_signed_cert = new JCheckBox("Ignore cert errors (self-signed, expired, etc.)? ");

// SSL - trust store
@Inject private KeyStorePanel jp_truststore;
Expand All @@ -41,7 +41,7 @@ public SSLReq getSslReq() {
SSLReqBean out = new SSLReqBean();

out.setHostNameVerifier(getSelectedHostnameVerifier());
out.setTrustSelfSignedCert(jcb_ssl_trust_self_signed_cert.isSelected());
out.setTrustAllCerts(jcb_ssl_trust_self_signed_cert.isSelected());

SSLKeyStore trustStore = jp_truststore.getKeyStore();
out.setTrustStore(trustStore);
Expand All @@ -63,7 +63,7 @@ public void setSslReq(SSLReq sslReq) {
jcb_disable_hostname_verifier.setSelected(false);
break;
}
jcb_ssl_trust_self_signed_cert.setSelected(sslReq.isTrustSelfSignedCert());
jcb_ssl_trust_self_signed_cert.setSelected(sslReq.isTrustAllCerts());

// truststore / keystore tab:
jp_truststore.setKeyStore(sslReq.getTrustStore());
Expand Down

0 comments on commit 4a3ca8b

Please sign in to comment.