Bug 51380 - [PATCH] Control reuse of cached SSL Context from iteration to iteration
Summary: [PATCH] Control reuse of cached SSL Context from iteration to iteration
Status: RESOLVED FIXED
Alias: None
Product: JMeter - Now in Github
Classification: Unclassified
Component: HTTP (show other bugs)
Version: 2.5
Hardware: All All
: P2 enhancement (vote)
Target Milestone: ---
Assignee: JMeter issues mailing list
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-06-15 16:34 UTC by Brent Cromarty
Modified: 2011-09-17 23:25 UTC (History)
2 users (show)



Attachments
Update to HTTPSampler2.java and jmeter.properties implementing SSL cache reuse control (21.54 KB, patch)
2011-06-15 16:41 UTC, Brent Cromarty
Details | Diff
Implementation of the feature (9.22 KB, patch)
2011-09-16 12:24 UTC, Philippe Mouawad
Details | Diff
Fix to the issue with corrected code format (I hope so) (8.90 KB, patch)
2011-09-16 14:00 UTC, Philippe Mouawad
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Brent Cromarty 2011-06-15 16:34:02 UTC

    
Comment 1 Brent Cromarty 2011-06-15 16:41:51 UTC
Created attachment 27162 [details]
Update to HTTPSampler2.java and jmeter.properties implementing SSL cache reuse control
Comment 2 Brent Cromarty 2011-06-15 16:55:18 UTC
Currently the HTTPClient sampler creates an SSL context and connection (i.e.: full handshake) for each thread on the first iteration only.  Subsequent iterations reuse their cached SSL Context thereby reusing an existing SSL handshake.  While this is typical of the way that a browser behaves (caching and reusing an SSL context where possible) it limits our ability to do specific testing of how a system will handle a constant load of N users when having to perform SSL transactions.

The patch I have proposed adds a new property "https.use.cached.ssl.context" to the jmeter.properties file.  The default value is "true" to preserve existing functionality.  If false the override of public void testIterationStart(LoopIterationEvent event) will get the SSL manager instance and call the resetContext() method, nulling the current threadLocal SSL context, and closing any currently open connections in the HTTP Client.

This allows us to create a new SSL context/connection each iteration, but reuse that context within the iteration.
Comment 3 Milamber 2011-06-26 17:51:37 UTC
Can you provide a diff patch with current trunk, not full plain files.
Thanks.
Comment 4 Philippe Mouawad 2011-09-16 12:24:13 UTC
Created attachment 27509 [details]
Implementation of the feature

Hello,
A note about implementation:
1) It works for HC3 and HC4 implementation
2) For Java Native HTTPSUrlConnection it doesn't work, SSL Context is cached and I don't see the method to reset it, if someone knows I will be interested.

To validate my patch I set:
-Djavax.net.debug=all

And count number of occurences of:
"trustStore is: /System/Library/Frameworks/JavaVM.framework/Versions/1.6.0/Home/lib/security/cacerts"

I note something strange:
- HC3 => 10 times => OK
- HC4 => 12 times => STRANGE ?
- Java => 1 time on first run then as it's in cache, regular since I don't reset it see note 2) above

Regards
Philippe
Comment 5 Milamber 2011-09-16 12:33:11 UTC
Please, respect code convention in JMeter for your patch.
Thanks.
http://wiki.apache.org/jakarta-jmeter/JMeterEclipse
Comment 6 Philippe Mouawad 2011-09-16 14:00:00 UTC
Created attachment 27511 [details]
Fix to the issue with corrected code format (I hope so)

If format is not OK please tell me what's wrong.
Regards
Philippe
Comment 7 Milamber 2011-09-16 14:12:37 UTC
Please Detab (and don't insert a new line before { on an If statement / methods (now fixed)
Comment 8 Sebb 2011-09-17 23:25:52 UTC
Thanks for the patch.

I simplified it somewhat by making the base implementation concrete, thus avoiding the need to provide implementations in all samplers.

Also made all the notifySSLContextWasReset() methods protected (some were public, not sure why).

URL: http://svn.apache.org/viewvc?rev=1172147&view=rev
Log:
Bug 51380 - Control reuse of cached SSL Context from iteration to iteration

Modified:
   jakarta/jmeter/trunk/bin/jmeter.properties
   jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPAbstractImpl.java
   jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC3Impl.java
   jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPHC4Impl.java
   jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSampler2.java
   jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerBase.java
   jakarta/jmeter/trunk/src/protocol/http/org/apache/jmeter/protocol/http/sampler/HTTPSamplerProxy.java
   jakarta/jmeter/trunk/xdocs/changes.xml
   jakarta/jmeter/trunk/xdocs/usermanual/component_reference.xml
Comment 9 The ASF infrastructure team 2022-09-24 20:37:46 UTC
This issue has been migrated to GitHub: https://github.com/apache/jmeter/issues/2501