Skip to Main Content

Java Security

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

javax.net.ssl.SSLException: bad handshake record MAC

843811Sep 22 2002 — edited Nov 30 2002
Hi all,
I have problem about SSL Extension in JSSE 1.0.3 with JDK1.3.01.
when I write testing program to test both SSL client and server socket,
for main of ssl socket server stting are:

static final String[] CIPHER_SUITES = { "SSL_RSA_WITH_RC4_128_MD5","SSL_RSA_WITH_RC4_128_SHA",
"SSL_RSA_WITH_DES_CBC_SHA","SSL_RSA_WITH_3DES_EDE_CBC_SHA",
"SSL_RSA_EXPORT_WITH_RC4_40_MD5" };
SSLContext ctx;
KeyManagerFactory kmf;
TrustManagerFactory tmf;
KeyStore ks;
SSLServerSocketFactory factory = null;
char[] passphrase = "changeit".toCharArray();

if( args[0].endsWith(".p12") )
ks = KeyStore.getInstance("pkcs12");
else
ks = KeyStore.getInstance("JKS");
ks.load( new FileInputStream(args[0]), passphrase );
tmf = TrustManagerFactory.getInstance("SunX509");
tmf.init( ks );

if( args[1].endsWith(".p12") )
ks = KeyStore.getInstance("pkcs12");
else
ks = KeyStore.getInstance("JKS");
ks.load( new FileInputStream(args[1]), passphrase );
kmf = KeyManagerFactory.getInstance("SunX509");
kmf.init( ks, passphrase );

ctx = SSLContext.getInstance("SSLv3","SunJSSE");
ctx.init( kmf.getKeyManagers(), tmf.getTrustManagers(), null );
factory = ctx.getServerSocketFactory();
SSLServerSocket socket = (SSLServerSocket)factory.createServerSocket( Integer.parseInt(args[2]) );
socket.setEnabledCipherSuites( CIPHER_SUITES );
socket.setNeedClientAuth( args.length==4 );

// in main loop --------
SSLSocket soc = (SSLSocket)socket.accept();
String[] css = soc.getEnabledCipherSuites();
System.err.println(" - Cipher suites:");
for(int i=0; i<css.length; i++)
System.err.println(" \""+css[i]+'"');
System.err.println(" - getEnableSessionCreation()="+soc.getEnableSessionCreation());
System.err.println(" - getNeedClientAuth()="+soc.getNeedClientAuth());
System.err.println(" - getUseClientMode()="+soc.getUseClientMode());
System.err.println(" - starting handshake "+soc);
soc.startHandshake();
System.err.println(" - accepted "+soc);
ThreadPool.getInstance().run( new SSLServer(soc) );
===
And the client has something same as server.
After run I caught error javax.net.ssl.SSLException: bad handshake record MAC at server and
javax.net.ssl.SSLException: Received fatal alert: handshake_failure (no cipher suites in common) at client side.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Dec 28 2002
Added on Sep 22 2002
3 comments
908 views