jmeter-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From pmoua...@apache.org
Subject svn commit: r1299216 - in /jmeter/trunk: src/protocol/http/org/apache/jmeter/protocol/http/util/HC4TrustAllSSLSocketFactory.java src/protocol/http/org/apache/jmeter/protocol/http/util/SlowHC4SSLSocketFactory.java xdocs/changes.xml
Date Sat, 10 Mar 2012 14:57:11 GMT
Author: pmouawad
Date: Sat Mar 10 14:57:11 2012
New Revision: 1299216

URL: http://svn.apache.org/viewvc?rev=1299216&view=rev
Log:
Bug 52871 - Multiple Certificates not working with HTTP Client 4

Modified:
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/HC4TrustAllSSLSocketFactory.java
    jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/SlowHC4SSLSocketFactory.java
    jmeter/trunk/xdocs/changes.xml

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/HC4TrustAllSSLSocketFactory.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/HC4TrustAllSSLSocketFactory.java?rev=1299216&r1=1299215&r2=1299216&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/HC4TrustAllSSLSocketFactory.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/HC4TrustAllSSLSocketFactory.java
Sat Mar 10 14:57:11 2012
@@ -18,11 +18,19 @@
 
 package org.apache.jmeter.protocol.http.util;
 
+import java.io.IOException;
+import java.net.Socket;
+import java.net.UnknownHostException;
 import java.security.GeneralSecurityException;
 import java.security.cert.X509Certificate;
 
+import javax.net.ssl.SSLSocket;
+
 import org.apache.http.conn.ssl.SSLSocketFactory;
 import org.apache.http.conn.ssl.TrustStrategy;
+import org.apache.http.params.HttpParams;
+import org.apache.jmeter.util.HttpSSLProtocolSocketFactory;
+import org.apache.jmeter.util.JsseSSLManager;
 
 /**
  * Apache HttpClient protocol factory to generate SSL sockets
@@ -35,6 +43,7 @@ public class HC4TrustAllSSLSocketFactory
             return true;
         }
     };
+    private javax.net.ssl.SSLSocketFactory factory;
 
     /**
      * Create an SSL factory which trusts all certificates and hosts.
@@ -42,6 +51,49 @@ public class HC4TrustAllSSLSocketFactory
      * @throws GeneralSecurityException if there's a problem setting up the security
      */
     public HC4TrustAllSSLSocketFactory() throws GeneralSecurityException {
+        this(new HttpSSLProtocolSocketFactory((JsseSSLManager)JsseSSLManager.getInstance()));
+    }
+    
+    /**
+     * Create an SSL factory which trusts all certificates and hosts.
+     * {@link SSLSocketFactory#SSLSocketFactory(TrustStrategy, org.apache.http.conn.ssl.X509HostnameVerifier)}

+     * @param factory javax.net.ssl.SSLSocketFactory 
+     * @throws GeneralSecurityException if there's a problem setting up the security
+     */
+    protected HC4TrustAllSSLSocketFactory(javax.net.ssl.SSLSocketFactory factory) throws
GeneralSecurityException {
         super(TRUSTALL, SSLSocketFactory.ALLOW_ALL_HOSTNAME_VERIFIER);
+        this.factory = new HttpSSLProtocolSocketFactory((JsseSSLManager)JsseSSLManager.getInstance());
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.http.conn.ssl.SSLSocketFactory#createSocket(org.apache.http.params.HttpParams)
+     */
+    @Override
+    public Socket createSocket(HttpParams params) throws IOException {
+        return factory.createSocket();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.http.conn.ssl.SSLSocketFactory#createSocket()
+     */
+    @Override
+    public Socket createSocket() throws IOException {
+        return factory.createSocket();
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.http.conn.ssl.SSLSocketFactory#createLayeredSocket(java.net.Socket,
java.lang.String, int, boolean)
+     */
+    @Override
+    public Socket createLayeredSocket(Socket socket, String host, int port,
+            boolean autoClose) throws IOException, UnknownHostException {
+        SSLSocket sslSocket = (SSLSocket) this.factory.createSocket(
+                socket,
+                host,
+                port,
+                autoClose
+                );
+        ALLOW_ALL_HOSTNAME_VERIFIER.verify(host, sslSocket);
+        return sslSocket;
     }
 }

Modified: jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/SlowHC4SSLSocketFactory.java
URL: http://svn.apache.org/viewvc/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/SlowHC4SSLSocketFactory.java?rev=1299216&r1=1299215&r2=1299216&view=diff
==============================================================================
--- jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/SlowHC4SSLSocketFactory.java
(original)
+++ jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/util/SlowHC4SSLSocketFactory.java
Sat Mar 10 14:57:11 2012
@@ -18,11 +18,10 @@
 
 package org.apache.jmeter.protocol.http.util;
 
-import java.net.Socket;
 import java.security.GeneralSecurityException;
 
-import org.apache.http.params.HttpParams;
-import org.apache.jmeter.util.SlowSocket;
+import org.apache.jmeter.util.HttpSSLProtocolSocketFactory;
+import org.apache.jmeter.util.JsseSSLManager;
 
 /**
  * Apache HttpClient protocol factory to generate "slow" SSL sockets for emulating dial-up
modems
@@ -30,8 +29,6 @@ import org.apache.jmeter.util.SlowSocket
 
 public class SlowHC4SSLSocketFactory extends HC4TrustAllSSLSocketFactory {
 
-    private final int CPS; // Characters per second to emulate
-
     /**
      * Create a factory 
      * @param cps - characters per second, must be > 0
@@ -39,22 +36,6 @@ public class SlowHC4SSLSocketFactory ext
      * @throws IllegalArgumentException if cps ≤ 0
      */
     public SlowHC4SSLSocketFactory(final int cps) throws GeneralSecurityException {
-        super();
-        if (cps <= 0) {
-            throw new IllegalArgumentException("CPS must be > 0, but is "+cps);
-        }
-        CPS = cps;
-    }
-
-    // Override all the socket creation methods in SSLSocketFactory
-    @Override
-    public Socket createSocket(final HttpParams params) {
-        return new SlowSocket(CPS);
-    }
-
-    @Override
-    public Socket createSocket() { // probably not used
-        return new SlowSocket(CPS);
+        super(new HttpSSLProtocolSocketFactory((JsseSSLManager)JsseSSLManager.getInstance(),
cps));
     }
-    
 }

Modified: jmeter/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jmeter/trunk/xdocs/changes.xml?rev=1299216&r1=1299215&r2=1299216&view=diff
==============================================================================
--- jmeter/trunk/xdocs/changes.xml (original)
+++ jmeter/trunk/xdocs/changes.xml Sat Mar 10 14:57:11 2012
@@ -73,6 +73,7 @@ When doing replacement of User Defined V
 <li>Bug 52613 - Using Raw Post Body option, text gets encoded</li>
 <li>Bug 52781 - Content-Disposition header garbled even if browser compatible headers
is checked (HC4) </li>
 <li>Bug 52796 - MonitorHandler fails to clear variables when starting a new parse</li>
+<li>Bug 52871 - Multiple Certificates not working with HTTP Client 4</li>
 </ul>
 
 <h3>Other Samplers</h3>



Mime
View raw message