RSA premaster secret error

Hello,

I'm developing a java tls ftp client. When I run it on my powebook (jdk 1.4.2_05) this works fine, however when I try to run the same code against the same server on windowsxp (jdk 1.5) I get an " RSA premaster secret error". My code is a slightly modified version of the code found in http://forum.java.sun.com/thread.jsp?forum=9&thread=535212

Does anybody know what the error means and how it can be fixed?

thanks,

Emiel.

For completeness here's the full output of the session:

234 AUTH TLS OK.

trigger seeding of SecureRandom

done seeding SecureRandom

export control - checking the cipher suites

export control - no cached value available...

export control - storing legal entry into cache...

%% No cached client session

*** ClientHello, TLSv1

RandomCookie: GMT: 1082374383 bytes = { 208, 252, 117, 151, 13, 69, 130, 81, 58, 49, 131, 77, 9, 48, 143, 3, 59, 255, 160, 14, 249, 58, 59, 8, 240, 150, 204, 74 }

Session ID: {}

Cipher Suites: [SSL_RSA_WITH_RC4_128_MD5, SSL_RSA_WITH_RC4_128_SHA, TLS_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_RSA_WITH_AES_128_CBC_SHA, TLS_DHE_DSS_WITH_AES_128_CBC_SHA, SSL_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_RSA_WITH_3DES_EDE_CBC_SHA, SSL_DHE_DSS_WITH_3DES_EDE_CBC_SHA, SSL_RSA_WITH_DES_CBC_SHA, SSL_DHE_RSA_WITH_DES_CBC_SHA, SSL_DHE_DSS_WITH_DES_CBC_SHA, SSL_RSA_EXPORT_WITH_RC4_40_MD5, SSL_RSA_EXPORT_WITH_DES40_CBC_SHA, SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA, SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA]

Compression Methods: { 0 }

***

[write] MD5 and SHA1 hashes: len = 73

0000: 01 00 00 45 03 01 41 84B9 EF D0 FC 75 97 0D 45 ...E..A.....u..E

0010: 82 51 3A 31 83 4D 09 308F 03 3B FF A0 0E F9 3A .Q:1.M.0..;....:

0020: 3B 08 F0 96 CC 4A 00 001E 00 04 00 05 00 2F 00 ;....J......../.

0030: 33 00 32 00 0A 00 16 0013 00 09 00 15 00 12 00 3.2.............

0040: 03 00 08 00 14 00 11 0100.........

main, WRITE: TLSv1 Handshake, length = 73

[write] MD5 and SHA1 hashes: len = 98

0000: 01 03 01 00 39 00 00 0020 00 00 04 01 00 80 00 ....9... .......

0010: 00 05 00 00 2F 00 00 3300 00 32 00 00 0A 07 00 ..../..3..2.....

0020: C0 00 00 16 00 00 13 0000 09 06 00 40 00 00 15 ............@...

0030: 00 00 12 00 00 03 02 0080 00 00 08 00 00 14 00 ................

0040: 00 11 41 84 B9 EF D0 FC75 97 0D 45 82 51 3A 31 ..A.....u..E.Q:1

0050: 83 4D 09 30 8F 03 3B FFA0 0E F9 3A 3B 08 F0 96 .M.0..;....:;...

0060: CC 4A .J

main, WRITE: SSLv2 client hello message, length = 98

main, READ: TLSv1 Handshake, length = 42

*** ServerHello, TLSv1

RandomCookie: GMT: 1082374383 bytes = { 52, 233, 60, 43, 185, 179, 44, 223, 26, 86, 103, 119, 13, 160, 194, 116, 2, 28, 53, 250, 46, 55, 90, 20, 56, 109, 52, 106 }

Session ID: {}

Cipher Suite: SSL_RSA_WITH_RC4_128_MD5

Compression Method: 0

***

%% Created: [Session-1, SSL_RSA_WITH_RC4_128_MD5]

** SSL_RSA_WITH_RC4_128_MD5

[read] MD5 and SHA1 hashes: len = 42

0000: 02 00 00 26 03 01 41 84B9 EF 34 E9 3C 2B B9 B3 ...&..A...4.<+..

0010: 2C DF 1A 56 67 77 0D A0C2 74 02 1C 35 FA 2E 37 ,..Vgw...t..5..7

0020: 5A 14 38 6D 34 6A 00 0004 00Z.8m4j....

main, READ: TLSv1 Handshake, length = 471

*** Certificate chain

chain [0] = [

[

Version: V3

Subject: EMAILADDRESS=none, CN=none, OU=none, O=none, L=none, ST=none, C=nl

Signature Algorithm: MD5withRSA, OID = 1.2.840.113549.1.1.4

Key: Sun RSA public key, 512 bits

modulus: 11098081486406261191796114211645654035308674233469313316362571139059657017831106491999436229882781613314634810526396154426211050331465166756403204277392009

public exponent: 65537

Validity: [From: Fri Sep 10 15:00:24 CEST 2004,

To: Sun Oct 10 15:00:24 CEST 2004]

Issuer: EMAILADDRESS=none, CN=none, OU=none, O=none, L=none, ST=none, C=nl

SerialNumber: [00]

]

Algorithm: [MD5withRSA]

Signature:

0000: 60 F6 7E F8 AC 4A 54 8694 B7 88 B0 B4 D4 B3 E0 `....JT.........

0010: AA F6 4C 96 C2 2B 7C 0F15 1D 45 47 D2 12 64 69 ..L..+....EG..di

0020: 36 09 02 9A D0 E7 BA AABD 24 72 4D 59 14 63 94 6........$rMY.c.

0030: B0 BB 37 45 7B AB 1B 027D BD 30 0F DF 47 3F 52 ..7E......0..G?R

]

***

The fingerprint of the certificate received is :

de31678c77bcb976bc056541e3b1e53

Do you want to trust on it? y/n...

y

adding as trusted cert:

Subject: EMAILADDRESS=none, CN=none, OU=none, O=none, L=none, ST=none, C=nl

Issuer: EMAILADDRESS=none, CN=none, OU=none, O=none, L=none, ST=none, C=nl

Algorithm: RSA; Serial number: 0x0

Valid from Fri Sep 10 15:00:24 CEST 2004 until Sun Oct 10 15:00:24 CEST 2004

Found trusted certificate:

[

[

Version: V3

Subject: EMAILADDRESS=none, CN=none, OU=none, O=none, L=none, ST=none, C=nl

Signature Algorithm: MD5withRSA, OID = 1.2.840.113549.1.1.4

Key: Sun RSA public key, 512 bits

modulus: 11098081486406261191796114211645654035308674233469313316362571139059657017831106491999436229882781613314634810526396154426211050331465166756403204277392009

public exponent: 65537

Validity: [From: Fri Sep 10 15:00:24 CEST 2004,

To: Sun Oct 10 15:00:24 CEST 2004]

Issuer: EMAILADDRESS=none, CN=none, OU=none, O=none, L=none, ST=none, C=nl

SerialNumber: [00]

]

Algorithm: [MD5withRSA]

Signature:

0000: 60 F6 7E F8 AC 4A 54 8694 B7 88 B0 B4 D4 B3 E0 `....JT.........

0010: AA F6 4C 96 C2 2B 7C 0F15 1D 45 47 D2 12 64 69 ..L..+....EG..di

0020: 36 09 02 9A D0 E7 BA AABD 24 72 4D 59 14 63 94 6........$rMY.c.

0030: B0 BB 37 45 7B AB 1B 027D BD 30 0F DF 47 3F 52 ..7E......0..G?R

]

[read] MD5 and SHA1 hashes: len = 471

0000: 0B 00 01 D3 00 01 D0 0001 CD 30 82 01 C9 30 82 ..........0...0.

0010: 01 73 A0 03 02 01 02 0201 00 30 0D 06 09 2A 86 .s........0...*.

0020: 48 86 F7 0D 01 01 04 0500 30 6D 31 0B 30 09 06 H........0m1.0..

0030: 03 55 04 06 13 02 6E 6C31 0D 30 0B 06 03 55 04 .U....nl1.0...U.

0040: 08 13 04 6E 6F 6E 65 310D 30 0B 06 03 55 04 07 ...none1.0...U..

0050: 13 04 6E 6F 6E 65 31 0D30 0B 06 03 55 04 0A 13 ..none1.0...U...

0060: 04 6E 6F 6E 65 31 0D 300B 06 03 55 04 0B 13 04 .none1.0...U....

0070: 6E 6F 6E 65 31 0D 30 0B06 03 55 04 03 13 04 6E none1.0...U....n

0080: 6F 6E 65 31 13 30 11 0609 2A 86 48 86 F7 0D 01 one1.0...*.H....

0090: 09 01 16 04 6E 6F 6E 6530 1E 17 0D 30 34 30 39 ....none0...0409

00A0: 31 30 31 33 30 30 32 345A 17 0D 30 34 31 30 31 10130024Z..04101

00B0: 30 31 33 30 30 32 34 5A30 6D 31 0B 30 09 06 03 0130024Z0m1.0...

00C0: 55 04 06 13 02 6E 6C 310D 30 0B 06 03 55 04 08 U....nl1.0...U..

00D0: 13 04 6E 6F 6E 65 31 0D30 0B 06 03 55 04 07 13 ..none1.0...U...

00E0: 04 6E 6F 6E 65 31 0D 300B 06 03 55 04 0A 13 04 .none1.0...U....

00F0: 6E 6F 6E 65 31 0D 30 0B06 03 55 04 0B 13 04 6E none1.0...U....n

0100: 6F 6E 65 31 0D 30 0B 0603 55 04 03 13 04 6E 6F one1.0...U....no

0110: 6E 65 31 13 30 11 06 092A 86 48 86 F7 0D 01 09 ne1.0...*.H.....

0120: 01 16 04 6E 6F 6E 65 305C 30 0D 06 09 2A 86 48 ...none0\0...*.H

0130: 86 F7 0D 01 01 01 05 0003 4B 00 30 48 02 41 00 .........K.0H.A.

0140: D3 E6 4A D5 43 85 F3 A05A 20 2C 0C 23 13 29 99 ..J.C...Z ,.#.).

0150: 29 1F 84 4D 87 90 CC AD10 C8 EB AF DF 55 8F F9 )..M.........U..

0160: 90 17 73 0F 5E 38 6A 3BB7 57 D8 77 AC 66 1C 13 ..s.^8j;.W.w.f..

0170: 42 FB 9E BD 1B 9D 46 2559 12 35 18 10 63 D2 89 B.....F%Y.5..c..

0180: 02 03 01 00 01 30 0D 0609 2A 86 48 86 F7 0D 01 .....0...*.H....

0190: 01 04 05 00 03 41 00 60F6 7E F8 AC 4A 54 86 94 .....A.`....JT..

01A0: B7 88 B0 B4 D4 B3 E0 AAF6 4C 96 C2 2B 7C 0F 15 .........L..+...

01B0: 1D 45 47 D2 12 64 69 3609 02 9A D0 E7 BA AA BD .EG..di6........

01C0: 24 72 4D 59 14 63 94 B0BB 37 45 7B AB 1B 02 7D $rMY.c...7E.....

01D0: BD 30 0F DF 47 3F 52.0..G?R

main, READ: TLSv1 Handshake, length = 4

*** ServerHelloDone

[read] MD5 and SHA1 hashes: len = 4

0000: 0E 00 00 00....

main, handling exception: javax.net.ssl.SSLKeyException: RSA premaster secret error

main, SEND TLSv1 ALERT: fatal, description = unexpected_message

main, WRITE: TLSv1 Alert, length = 2

main, called closeSocket()

Error in FtpClient.login()

FtpException: Error in startHandSkake() javax.net.ssl.SSLKeyException: RSA premaster secret error

[8696 byte] By [evl] at [2007-9-30 21:10:33]
# 1
Update: I've also tested this on my linux box using jdk1.5 and I get the same results (failure). However when I run the code on my linux box using jdk 1.4.2 it *does* work. Obviously something changed in jsse between 1.4 and 1.5...
evl at 2007-7-7 2:43:33 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 2
Got the same problem using martyr (irc framework) to connect to an irc server. Problems seems to have appeared when i switched to SDK 1.5.0. Will have to downgrade to solve this.Did you find any solutions to getting this working with 1.5?Thanks
mooog at 2007-7-7 2:43:33 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 3

It works now, i'm not entirely sure what was wrong but it seems to have been a problem with JCE.

With 1.4 and JCE installed i got the error "javax.net.ssl.SSLException: java.lang.SecurityException: JCE cannot authenticate the provider SunJCE".

Using gentoo i merged sun-jdk with USE=jce, i must have missed something initially but now it works with bot 1.4.2-06 and 1.5.0.

Cheers

mooog at 2007-7-7 2:43:33 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 4
I found the specific cause. It only happens when i launch through my IDE, eclipse.
mooog at 2007-7-7 2:43:33 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 5
... and only in debug mode...****, should have figured this out earlier.
mooog at 2007-7-7 2:43:33 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 6
Yes it is eclipse. But on my side it is not debug mode or default run mode.On my side it the the jre.If i select the jre1.5 it produces the errorIf i select the jdk/jre1.5 it works fineBut i have no idea whats the differenceCUSebastian
picpromusic at 2007-7-7 2:43:33 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 7

Hi ,

I am also getting the error RSA premaster secret error while invoking via JRE 1.5.

However, it works fine with JDK 1.5.

Do anybody have solution, kindly help me.

The trace goes as follows

javax.net.ssl.SSLKeyException: RSA premaster secret error

at com.sun.net.ssl.internal.ssl.PreMasterSecret.<init>(Unknown Source)

at com.sun.net.ssl.internal.ssl.ClientHandshaker.serverHelloDone(Unknown Source)

Thanks & Regards

Raghavan

srinivasar_java at 2007-7-7 2:43:33 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 8
Can you please explain in detail as to how you got rid of this problem. Thanks and Happy New Year
mpoddar2 at 2007-7-7 2:43:33 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 9
I had the same error running debug in Eclipse. To fix it apart from selecting the jre from inside the jdk I also had to select Use default system libraries
obender2 at 2007-7-7 2:43:33 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 10
see also http://forum.java.sun.com/thread.jspa?threadID=581431
ralfhauser at 2007-7-7 2:43:33 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 11

Download and install the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files version 5.0. http://java.sun.com/j2se/1.5.0/download.jsp

Due to import control restrictions, the version of JCE policy files that

are bundled in the JDK(TM) 5.0 environment allow "strong" but limited

cryptography to be used.

kozmoz at 2007-7-7 2:43:33 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 12
see also http://www.bouncycastle.org/devmailarchive/msg04733.html
ralfhauser at 2007-7-7 2:43:33 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 13
since it really appears to be an eclipse problem, I also opened a bug there https://bugs.eclipse.org/bugs/show_bug.cgi?id=95898
ralfhauser at 2007-7-7 2:43:33 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 14

I have encountered this same error when running the wscompile utility against WSDL on a site with SSL. I have downloaded and installed the revised policy files to no avail. I am using the JDK1.5.0_03 and JWSDP 1.5. I get the same error regardless of running from within eclipse or from a command line prompt. Any assistance would be appreciated.

cnbradley1 at 2007-7-7 2:43:33 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 15
What exactly are the allowed specifications without the JCE policy files download? I'm trying to author a JWS application to run on a client site and don't want to tell my clients to download these updates
caspiralinksa at 2007-7-20 0:22:31 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 16
i am also getting an RSA premaster secret error with wsdl. has anyone been able to resolve this yet?
Adi_Shaha at 2007-7-20 0:22:31 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 17

Hello,

I am getting the same error when I try to connect to ADS via SSl. I obtained the strong policy files from sun. But to no avail still get the same errors using jdk1.5 or jre1.5.

I even downloaded a service provider from BouncyCastle, made the following entry in the secuirty file

security.provider.4=org.bouncycastle.jce.provider.BouncyCastleProvider.

Put the jar in the lib/ext directory. Still the same error. Is there any provider which would support this Alogirthm.

I am relatively new to all these concepts, I even logged a bug on Sun .

Please help.

zbhiwandiwalaa at 2007-7-20 0:22:31 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 18

Hello All,

I did download the strong policy files from Sun. My application used a policy file which was created by me.

When I excuted the application my command prompt was as follows

java -classpath jtds-1.1.jar;OitApplication.jar;OitLM.jar -Djava.security.manager -Djava.security.policy==oit.policy -Djava.security.auth.login.config==oit_jaas.config com.docfinity.application.LoginManager

Now when you use ==

it signifies that you want to explicitly use the policy file oit.policy and the login.config. file oit_jaas.config.

Because I explicitly used my own policy file which contained the following

grant codebase "file:./OitLM.jar" {

permission java.security.AllPermission ;

};

grant codebase "file:./jtds-1.1.jar" {

permission java.security.AllPermission ;

};

grant codebase "file:./OitApplication.jar" {

permission java.security.AllPermission ;

}; .............

I had bypassed granting the libraries in the <JAVA_HOME> \jre\lib\ext

access permissions. Which is present in the deafult policy file.

i.e.

grant codeBase "file:${{java.ext.dirs}}/*" {

permission java.security.AllPermission;

};

Now one way to get rid of the error was to use = as opposed to ==.

This way the default policy file got included.

The other thing was to include this in the custom policy file.

grant codeBase "file:${{java.ext.dirs}}/sunjce_provider.jar" {

permission java.security.AllPermission;

};

.

Thanks to Jeff Moroski, our System Architect we could find this out.

Hope this solution helps all of you.

Regards

Zoharat

zbhiwandiwalaa at 2007-7-20 0:22:31 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 19

> Download and install the Java Cryptography Extension

> (JCE) Unlimited Strength Jurisdiction Policy Files

> version 5.0.

> http://java.sun.com/j2se/1.5.0/download.jsp

>

> Due to import control restrictions, the version of

> JCE policy files that

> are bundled in the JDK(TM) 5.0 environment allow

> "strong" but limited

> cryptography to be used.

install this cannot work.

same java code, ok on jdk1.4 and NG on jdk5.0 ,

has someone report this bug to sun?

neoedmunda at 2007-7-20 0:22:31 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 20
I am getting the same error in 1.5, and cannot revert to 1.4!HELP!!!Todd
mushenoa at 2007-7-20 0:22:31 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 21
HiSee if the information if the information in the following post will help. http://forum.java.sun.com/thread.jspa?threadID=587480&messageID=4219591Thanks
parvina at 2007-7-20 0:22:31 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 22
HiSee if the information if the information in the following post will help. http://forum.java.sun.com/thread.jspa?threadID=587480&messageID=4219591Thanks
parvina at 2007-7-20 0:22:31 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...
# 23

> Download and install the Java Cryptography Extension (JCE) Unlimited Strength Jurisdiction Policy Files version 5.0.

This suggestion works for me, thanks. This solved the "Premaster secret error" for me, which I was suffering under both Windows and Linux.

> Due to import control restrictions, the version of JCE policy files that

> are bundled in the JDK(TM) 5.0 environment allow "strong" but limited

> cryptography to be used.

This part I'm not so convinced about. I can give the entire log, but the upshot of it all is that for my connection (both with and without the policy files) the negotiated cipher suite was SSL_RSA_WITH_RC4_128_MD5, which hardly seems like something that should be subjected to import/export restrictions. In any case, the way SSL works, the client (in this case JSSE) offers up a list of ciphers it supports. The server mulls this over and picks one of the list. If JSSE intends to balk at SSL_RSA_WITH_RC4_128_MD5, it ought not to offer this as a choice during the Client Hello message.

PaulSa at 2007-7-20 0:22:31 > top of Java-index,Security,Java Secure Socket Extension (JSSE)...