Implement Always trust mode for verifying certificates, and enable the mode for tests.

cusax-fix
Damian Minkov 16 years ago
parent 2a49a5de69
commit b841366922

@ -1257,6 +1257,10 @@ public void checkClientTrusted(X509Certificate[] chain, String authType)
public void checkServerTrusted(X509Certificate[] chain, String authType)
throws CertificateException
{
if(JabberActivator.getConfigurationService().getBoolean(
CertificateVerificationService.ALWAYS_TRUST_MODE_ENABLED_PROP_NAME,
false))
return;
try
{
tm.checkServerTrusted(chain, authType);

@ -451,6 +451,11 @@ public void checkClientTrusted(X509Certificate[] chain, String authType)
public void checkServerTrusted(X509Certificate[] chain, String authType)
throws CertificateException
{
if(SipActivator.getConfigurationService().getBoolean(
CertificateVerificationService.ALWAYS_TRUST_MODE_ENABLED_PROP_NAME,
false))
return;
try
{
tm.checkServerTrusted(chain, authType);

@ -16,6 +16,12 @@
*/
public interface CertificateVerificationService
{
/**
* Property for always trust mode. When enabled certificate check is skipped.
*/
public final static String ALWAYS_TRUST_MODE_ENABLED_PROP_NAME =
"net.java.sip.communicator.service.gui.ALWAYS_TRUST_MODE_ENABLED";
/**
* Result of user interaction. User don't trust this certificate.
*/

@ -10,6 +10,8 @@
import org.osgi.framework.*;
import junit.framework.*;
import net.java.sip.communicator.service.configuration.*;
import net.java.sip.communicator.service.gui.*;
import net.java.sip.communicator.service.protocol.*;
public class TestAccountInstallation
@ -66,6 +68,16 @@ public void testInstallAccount()
"Failed to find a provider factory service for protocol Jabber",
serRefs != null && serRefs.length > 0);
// Enable always trust mode for testing tls jabber connections
ServiceReference confReference
= JabberSlickFixture.bc.getServiceReference(
ConfigurationService.class.getName());
ConfigurationService configurationService
= (ConfigurationService) JabberSlickFixture.bc.getService(confReference);
configurationService.setProperty(
CertificateVerificationService.ALWAYS_TRUST_MODE_ENABLED_PROP_NAME,
Boolean.TRUE);
//Keep the reference for later usage.
ProtocolProviderFactory jabberProviderFactory = (ProtocolProviderFactory)
JabberSlickFixture.bc.getService(serRefs[0]);

Loading…
Cancel
Save