Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSL connection leads to ArrayStoreException on JDK 6 with some KeyManagerFactory SPI #2847

Closed
asfimport opened this issue Jun 20, 2012 · 10 comments

Comments

@asfimport
Copy link
Collaborator

Patrick Heusser (Bug 53440):
On Windows with JDK 6 when establishing a connection over SSL i got the stack posted below with the array ArrayStoreException... This is reproducable and does NOT happen on a JDK 5 installation.

This happens just at runtime. The code can be compiled with JDK 5 and JDK 6...

Exact java version that produces the error:

java -version
java version "1.6.0_30"
Java(TM) SE Runtime Environment (build 1.6.0_30-b12)
Java HotSpot(TM) Client VM (build 20.5-b03, mixed mode, sharing)

workaround:
Use a JDK 1.5

STACK-TRACE

java.lang.ArrayStoreException: org.apache.jmeter.util.JsseSSLManager$WrappedX509KeyManager
at org.apache.jmeter.util.JsseSSLManager.createContext(JsseSSLManager.java:241)
at org.apache.jmeter.util.JsseSSLManager.getContext(JsseSSLManager.java:198)
at org.apache.jmeter.util.HttpSSLProtocolSocketFactory.getSSLSocketFactory(HttpSSLProtocolSocketFactory.java:103)
at org.apache.jmeter.util.HttpSSLProtocolSocketFactory.createSocket(HttpSSLProtocolSocketFactory.java:147)
at org.apache.commons.httpclient.HttpConnection.open(HttpConnection.java:707)
at org.apache.commons.httpclient.HttpMethodDirector.executeWithRetry(HttpMethodDirector.java:387)
at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:171)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
at org.apache.jmeter.protocol.http.sampler.HTTPHC3Impl.sample(HTTPHC3Impl.java:249)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerProxy.sample(HTTPSamplerProxy.java:62)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1060)
at org.apache.jmeter.protocol.http.sampler.HTTPSamplerBase.sample(HTTPSamplerBase.java:1049)
at org.apache.jmeter.threads.JMeterThread.process_sampler(JMeterThread.java:442)
at org.apache.jmeter.threads.JMeterThread.run(JMeterThread.java:271)
at java.lang.Thread.run(Unknown Source)

Best regards,
patrick

Severity: normal
OS: Windows XP

@asfimport
Copy link
Collaborator Author

Sebb (migrated from Bugzilla):
The code in question is:

KeyManager[] managers = managerFactory.getKeyManagers();
...
for (int i = 0; i < managers.length; i++) {
if (managers[i] instanceof X509KeyManager) {
X509KeyManager manager = (X509KeyManager) managers[i];
managers[i] = new WrappedX509KeyManager(manager, keys); // line 241
}
}

Now WrappedX509KeyManager implements X509KeyManager which extends KeyManager.
I don't see how the code would even compile unless this were true, so an ArrayStoreException should be impossible.

I've tried with java.version=1.6.0_31 on Windows and it works fine for me.

Please can you provide the simplest possible test script that shows the problem, along with log files for Java 1.5 and 1.6?

@asfimport
Copy link
Collaborator Author

Patrick Heusser (migrated from Bugzilla):
hi

thx for looking at it.

i had a quick look at the code too. for both java API 1.5 and 1.6 the hierarchy is the same and it compiles with both, but does fail at runtime. so it must be obviously related to the JDK and NOT Jmeter itself. it would be nice, if Jmeter could work "around" it. the sampler with the request fails completely, may be a simple try/catch helps.

our server under test asks for a client certificate, even though it's not required in the end. my guess is this causes the failure.

regards,

@asfimport
Copy link
Collaborator Author

Sebb (migrated from Bugzilla):
We really need to be able to reproduce the issue.

Can you provide a simple test case that exhibits the problem, together with any changes you made to jmeter.properties or system.properties?

Also, it would be helpful to have the jmeter logs for both runs.

If necessary, feel free to replace the names of servers etc with place-holders.

Also, just in case it is a specific issue with Java 1.6.0_30, can you try with the current release, i.e. 1.6.0_33?

@asfimport
Copy link
Collaborator Author

Sebb (migrated from Bugzilla):
I've managed now to set up a test with Tomcat.
It uses clientAuth="true" and requires a certificate.

I was able to connect to Tomcat with Firefox and with JMeter; no problems were encountered with 1.5.0_22, 1.6.0_33, 1.7.0_05.

This is looking like a problem with your Java 6 installation, i.e. the bug should be closed as "WORKSFORME" unless you can provide a test case that can be repeated by others.

@asfimport
Copy link
Collaborator Author

@pmouawad (migrated from Bugzilla):
Hello Sebb,
I think issue is possible because we don't know the real type of array allocated.

Take the following snippet:
public static void main(String[] args) {
Number[] t = new Integer[5];
t[0] = new Long(123);
}

Long is a Number but it provokes an ArrayStoreException cause allocated array elements if not a Long array.

@asfimport
Copy link
Collaborator Author

@pmouawad (migrated from Bugzilla):
To be clearer it can happen if SPI does not allocate a KeyManager array but a subclass.

@asfimport
Copy link
Collaborator Author

@pmouawad (migrated from Bugzilla):
Date: Sat Jun 23 22:06:21 2012
New Revision: 1353205

URL: http://svn.apache.org/viewvc?rev=1353205&view=rev
Log:
#2847 - SSL connection leads to ArrayStoreException on JDK 6 with some KeyManagerFactory SPI
#2847

Modified:
jmeter/trunk/src/core/org/apache/jmeter/util/JsseSSLManager.java
jmeter/trunk/xdocs/changes.xml

@asfimport
Copy link
Collaborator Author

@pmouawad (migrated from Bugzilla):
Hello M. Heusser,
It would be helpful if you could confirm that issue is fixed for you using a nightly build that will be generated within hours.

@asfimport
Copy link
Collaborator Author

Patrick Heusser (migrated from Bugzilla):
hi jmeter team

i did some more testing with different JVM versions. i found, that my observation is very specific to the version i used (see bug submission). i did tests with the two version listed below, both work OK!

still, i gonna try your nightly fix. sorry to be a bit slow on that, i'm in a rather restricted environment where it's a bit hard to test such stuff...

one note: i'm extremely impressed by the work and commitment that you guys do. respect and thanks a lot! JMeter is a cool tool :-)

JVM WORKS OK:
D:\Data\Rad\shared\programs\Java\jre6_32bit\bin>java -version
java version "1.6.0_33"
Java(TM) SE Runtime Environment (build 1.6.0_33-b03)
Java HotSpot(TM) Client VM (build 20.8-b03, mixed mode, sharing)

JVM WORKS OK:
D:\Data\Rad\shared\programs\Java\jdk1.7.0_05_32bit\bin>java -version
java version "1.7.0_05"
Java(TM) SE Runtime Environment (build 1.7.0_05-b05)
Java HotSpot(TM) Client VM (build 23.1-b03, mixed mode)

cheers,
patrick

@asfimport
Copy link
Collaborator Author

Patrick Heusser (migrated from Bugzilla):
hi guys

i tested the nightly build r1353803 this morning.

=> it was a full success! the exception has gone.

thanks a lot,
patrick

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant