Spark-1787 Add option to disable TLS hostname verification (#207)

* Added option to disable tls hostname verification

* Spark-1787  Small change to text
This commit is contained in:
Speedy
2016-08-27 01:19:54 -05:00
committed by wroot
parent 36627d3806
commit 8ffa4a2188
4 changed files with 21 additions and 4 deletions

View File

@ -254,7 +254,10 @@ public class LoginDialog {
} catch (NoSuchAlgorithmException | KeyManagementException e) {
Log.warning( "Unable to create configuration.", e );
}
}
}
if (localPref.isDisableHostnameVerification()) {
TLSUtils.disableHostnameVerificationForTlsCertificicates(builder);
}
if ( localPref.isDebuggerEnabled()) {
builder.setDebuggerEnabled( true );
}

View File

@ -36,6 +36,7 @@ class GeneralLoginSettingsPanel extends JPanel implements ActionListener
private JCheckBox compressionBox = new JCheckBox();
private JCheckBox debuggerBox = new JCheckBox();
private JCheckBox acceptAllCertificatesBox = new JCheckBox();
private JCheckBox disableHostnameVerificationBox = new JCheckBox();
public GeneralLoginSettingsPanel( LocalPreferences localPreferences, JDialog optionsDialog )
{
@ -58,7 +59,7 @@ class GeneralLoginSettingsPanel extends JPanel implements ActionListener
ResourceUtils.resButton( compressionBox, Res.getString( "checkbox.use.compression" ) );
ResourceUtils.resButton( debuggerBox, Res.getString( "checkbox.use.debugger.on.startup" ) );
ResourceUtils.resButton( acceptAllCertificatesBox, Res.getString( "checkbox.accept.all.certificates" ) );
ResourceUtils.resButton( disableHostnameVerificationBox, Res.getString( "checkbox.disable.hostname.verification" ) );
portField.setText( Integer.toString( localPreferences.getXmppPort() ) );
timeOutField.setText( Integer.toString( localPreferences.getTimeOut() ) );
autoLoginBox.setSelected( localPreferences.isAutoLogin() );
@ -85,6 +86,8 @@ class GeneralLoginSettingsPanel extends JPanel implements ActionListener
acceptAllCertificatesBox.setSelected( localPreferences.isAcceptAllCertificates() );
disableHostnameVerificationBox.setSelected( localPreferences.isDisableHostnameVerification() );
final JPanel connectionPanel = new JPanel();
connectionPanel.setLayout( new GridBagLayout() );
connectionPanel.setBorder( BorderFactory.createTitledBorder( Res.getString( "group.connection" ) ) );
@ -112,7 +115,8 @@ class GeneralLoginSettingsPanel extends JPanel implements ActionListener
add( useSSLBox, new GridBagConstraints( 0, 6, 2, 1, 0.0, 1.0, WEST, HORIZONTAL, DEFAULT_INSETS, 0, 0 ) );
add( compressionBox, new GridBagConstraints( 0, 7, 2, 1, 0.0, 1.0, WEST, HORIZONTAL, DEFAULT_INSETS, 0, 0 ) );
add( acceptAllCertificatesBox, new GridBagConstraints( 0, 8, 2, 1, 0.0, 1.0, WEST, HORIZONTAL, DEFAULT_INSETS, 0, 0 ) );
add( debuggerBox, new GridBagConstraints( 0, 9, 2, 1, 0.0, 1.0, WEST, HORIZONTAL, DEFAULT_INSETS, 0, 0 ) );
add( disableHostnameVerificationBox, new GridBagConstraints( 0, 9, 2, 1, 0.0, 1.0, WEST, HORIZONTAL, DEFAULT_INSETS, 0, 0 ) );
add( debuggerBox, new GridBagConstraints( 0, 10, 2, 1, 0.0, 1.0, WEST, HORIZONTAL, DEFAULT_INSETS, 0, 0 ) );
}
/**
@ -247,6 +251,7 @@ class GeneralLoginSettingsPanel extends JPanel implements ActionListener
localPreferences.setUseHostnameAsResource( useHostnameAsResourceBox.isSelected() );
localPreferences.setUseVersionAsResource( useVersionAsResourceBox.isSelected() );
localPreferences.setAcceptAllCertificates( acceptAllCertificatesBox.isSelected() );
localPreferences.setDisableHostnameVerification( disableHostnameVerificationBox.isSelected() );
SettingsManager.saveSettings();
}
}

View File

@ -1162,6 +1162,14 @@ public class LocalPreferences {
return getBoolean("AcceptAllCertificates", true);
}
public void setDisableHostnameVerification(boolean accept) {
setBoolean("DisableHostnameVerification", accept);
}
public boolean isDisableHostnameVerification() {
return getBoolean("DisableHostnameVerification", false);
}
private boolean getBoolean(String property, boolean defaultValue) {
return Boolean.parseBoolean(props.getProperty(property, Boolean
.toString(defaultValue)));

View File

@ -379,7 +379,8 @@ checkbox.transport.tab.setting = Show available transports in tab (requires rest
checkbox.conference.tab.setting = Show conference service in tab (requires restart)
checkbox.use.hostname.as.resource = Use hostname as resource
checkbox.use.version.as.resource = Use Spark version as resource
checkbox.accept.all.certificates = Accept all certificates
checkbox.accept.all.certificates = Accept all certificates (e.g. Self-Signed/Expired/etc)
checkbox.disable.hostname.verification = Disable certificate hostname verification (Not Recommended)
delete.log.permanently = Permanently delete log
delete.permanently = Permanently delete?