ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » General Discussion » Java standalone and SSL - MQ Series6 support

Post new topic  Reply to topic
 Java standalone and SSL - MQ Series6 support « View previous topic :: View next topic » 
Author Message
mqguy21
PostPosted: Wed Jan 24, 2007 1:59 am    Post subject: Java standalone and SSL - MQ Series6 support Reply with quote

Newbie

Joined: 24 Jan 2007
Posts: 3

I am able to run my standalone Java program by specifying trust store details etc from command line like java -Djavax.net.ssl.keyStore=C:\MYAPPJ\myappj.jks -Djavax.net.ssl.keyStorePassword=abc123 -Djavax.net.ssl.trustStore=C:\MYAPPJ\myappj.jks MyStandaloneTest SYSTEM.DEFAULT.LOCAL.QUEUE myqmgrname.

But I am NOT able to run my program by specifying trust details in java class either by

HashMap h1 = new HashMap();
h1.put("javax.net.ssl.keyStore","C:\\MYAPPJ\\myappj.jks");
h1.put("javax.net.ssl.keyStorePassword", "abc123");
h1.put("javax.net.ssl.trustStore","C:\\MYAPPJ\\myappj.jks");
h1.put("javax.net.ssl.trustStorePassword", "abc123");

Collection c = h1.entrySet();
MQEnvironment.sslCertStores = c ;

OR

System.setProperty( "javax.net.ssl.keyStore", "C:\\MYAPPJ\\myappj.jks");
System.setProperty( "javax.net.ssl.keyStorePassword", "abc123" );
System.setProperty( "javax.net.ssl.trustStore", "C:\\MYAPPJ\\myappj.jks");
System.setProperty( "javax.net.ssl.trustStorePassword", "abc123");

ERROR:
MQException: com.ibm.mq.MQException: MQJE001: Completion Code 2, Reason 2397 JSSE Exception: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found

Please help me to resolve this.
_________________
MQ Guy
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Jan 24, 2007 2:24 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

You probably need to apply the certificates as laid out in the Using Security manual.
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mqguy21
PostPosted: Wed Jan 24, 2007 2:51 am    Post subject: Reply with quote

Newbie

Joined: 24 Jan 2007
Posts: 3

Thank you!!!

Can you please send me the URL link for Security manual.
_________________
MQ Guy
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Jan 24, 2007 3:13 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

mqguy21 wrote:
Thank you!!!

Can you please send me the URL link for Security manual.


Hard to see how you've missed this on even a casual browse of the forum but:

http://publib.boulder.ibm.com/infocenter/wmqv6/v6r0/index.jsp

You'll find all the manuals in there.

Happy Reading!
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
mqguy21
PostPosted: Wed Jan 24, 2007 5:32 am    Post subject: Reply with quote

Newbie

Joined: 24 Jan 2007
Posts: 3

Thanks for URL.

Tried but not able to find answer for it. Direct answer is much appreciated. Please find my standalone java class below.

Code:
import com.ibm.mq.*;
import java.util.HashMap;
import java.util.Collection;

public class PutSample
{
// usage: java PutSample qname qmgrname
//
public static void main(String args[])
{
try
{
// setup CLNTCONN channel details
MQEnvironment.hostname = "localhost";
MQEnvironment.port = 1420;
MQEnvironment.channel = "MY.SEC.SVRCONN.CHL1";
MQEnvironment.sslCipherSuite = "SSL_RSA_WITH_RC4_128_MD5";

MQEnvironment.sslKeyStore="C:\\MYAPPJ\\myappj.jks";

//System.setProperty( "javax.net.ssl.keyStore", "C:\\MYAPPJ\\myappj.jks");
//System.setProperty( "javax.net.ssl.keyStorePassword", "abc123" );
//System.setProperty( "javax.net.ssl.trustStore", "C:\\MYAPPJ\\myappj.jks");
//System.setProperty( "javax.net.ssl.trustStorePassword", "abc123");

HashMap h1 = new HashMap();
h1.put("javax.net.ssl.keyStore","C:\\MYAPPJ\\myappj.jks");
h1.put("javax.net.ssl.keyStorePassword", "abc123");
h1.put("javax.net.ssl.trustStore","C:\\MYAPPJ\\myappj.jks");
h1.put("javax.net.ssl.trustStorePassword", "abc123");

Collection c = h1.entrySet();
MQEnvironment.sslCertStores = c ;

// connect
MQQueueManager qMgr = new MQQueueManager(args[1]);
System.out.println("qmgr construction successful");
// open
int OpenOptions = MQC.MQOO_OUTPUT;
MQQueue queue = qMgr.accessQueue(args[0], OpenOptions);
System.out.println("qmgr.accessQueue() successful");
// create message
MQMessage msg = new MQMessage();
msg.format = MQC.MQFMT_STRING;
msg.writeString("Hello, World!");
MQPutMessageOptions pmo = new MQPutMessageOptions();
// put
queue.put(msg, pmo);
System.out.println("queue.put() successful");
// cleanup (1)
queue.close();
// give user 30 seconds to run DISPLAY CHSTATUS
System.out.println("Sleeping for 30 seconds");
try
{
java.lang.Thread.sleep(30000);
}
catch (InterruptedException ie)
{
System.out.println("InterruptedException: " + ie);
}
// cleanup (2)
qMgr.disconnect();
System.out.println("Success");
}
catch (MQException ex)
{
System.out.println("MQException: " + ex);
if ( ex.reasonCode == MQException.MQRC_JSSE_ERROR )
System.out.println("JSSE Exception: " + ex.getCause());
}
catch (java.io.IOException ex)
{
System.out.println("IOException: " + ex);
}
}
}

_________________
MQ Guy
Back to top
View user's profile Send private message
Vitor
PostPosted: Wed Jan 24, 2007 5:39 am    Post subject: Reply with quote

Grand High Poobah

Joined: 11 Nov 2005
Posts: 26093
Location: Texas, USA

Which part of the section on MQ's SSL support ("Websphere MQ SSL Support" section in the manual) was unclear to you?

This has step by step instructions for setup....
_________________
Honesty is the best policy.
Insanity is the best defence.
Back to top
View user's profile Send private message
vennela
PostPosted: Wed Jan 24, 2007 6:11 am    Post subject: Reply with quote

Jedi Knight

Joined: 11 Aug 2002
Posts: 4055
Location: Hyderabad, India

Have you created the keyStore and TrustStore
How did you do it
Back to top
View user's profile Send private message Send e-mail Visit poster's website
mvic
PostPosted: Thu Jan 25, 2007 5:31 pm    Post subject: Re: Java standalone and SSL - MQ Series6 support Reply with quote

Jedi

Joined: 09 Mar 2004
Posts: 2080

mqguy21 wrote:

ERROR:
MQException: com.ibm.mq.MQException: MQJE001: Completion Code 2, Reason 2397 JSSE Exception: javax.net.ssl.SSLHandshakeException: sun.security.validator.ValidatorException: No trusted certificate found

Please help me to resolve this.

The java.lang.System.setProperty calls seem better to me.

But I can't see why your cmd line works but the in-program setting doesn't.

It says "No trusted certificate found". Are you running the program as the same user, on the same machine... are there any other differences at runtime between the failing and succeeding cases?

I note you have "trustStorePassword" in the program but not on the cmd line... significant? Perhaps try with it removed from the program.

What JRE/JDK are you running?
Back to top
View user's profile Send private message
hejunion@gmail.com
PostPosted: Mon Mar 05, 2007 9:37 pm    Post subject: Object stored in MQEnvironment.sslCertStores Reply with quote

Newbie

Joined: 05 Mar 2007
Posts: 1

You can not just assign the key-property pair to this.

MQEnvironment.sslCertStores is a Collection,
Need create ArrayList of CertStore objects defined for the trust store.
Back to top
View user's profile Send private message
rd123
PostPosted: Sat Jul 05, 2008 8:44 am    Post subject: Reply with quote

Newbie

Joined: 05 Jul 2008
Posts: 1

I am getting same error. the program does not seem to pick the ssl certs from repository. How did you get this working
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » General Discussion » Java standalone and SSL - MQ Series6 support
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.