Skip to main content link. Accesskey S
  • Anonymous
  • Log on
  • Help
  • IBM logo
  • Lotus Expeditor wiki
  • All Wikis
  • Home
  • Community Articles
  • Product Documentation
  • Learning Center


Search

Advanced Search

Categories

Tag Cloud

  • 6.2.1
  • 6.2.2
  • 6.2.3
  • access services
  • accounts
  • administer
  • application
  • applications
  • broker
  • client
  • client for desktop
  • client management
  • cluster
  • collecting data
  • configuration
  • configure
  • data integrity check tools
  • database
  • db2
  • db2e
  • deleting log entries automatically
  • demo
  • demonstration
  • desktop overview
  • develop
  • device
  • device client
  • diagnosis of problems. See troubleshooting
  • diagnostic data
  • diagnostic tool
  • documentation
  • download
  • environment variables
  • error messages
  • expeditor
  • expeditor server
  • expeditor toolkit
  • files
  • fix pack
  • gettingstarted
  • Help
  • how-to
  • IBM Support
  • install
  • installation
  • integration
  • integrator
  • interaction services
  • Interrogation Windows Tab
  • introduce
  • introduction
  • log files
  • messaging
  • micro
  • mobile databases
  • mobile databases
  • mobile devices
  • mqe
  • nci
  • notes
  • OpenSpan
  • OpenSpan Scripting Container
  • OpenSpan Windows Container
  • overview
  • platform
  • portlet
  • prerequisites
  • presentation
  • problems with synchronization. See troubleshooting.
  • purging log entries automatically
  • Release Notes
  • replication
  • resources on the Web
  • rich client application
  • samples
  • scripts
  • security
  • server
  • software
  • software prerequisites
  • support
  • support troubleshooting
  • Sync Client
  • Sync Server
  • synchronization
  • synchronization problems
  • tool
  • toolkit
  • tools
  • trace files
  • trace level
  • troubleshoot
  • troubleshooting
  • tutorial
  • use
  • was
  • web services
  • What's New
  • xcm
  • xpdt
InformationInformation
You are currently viewing machine translated content. IBM translation might be available. Click IBM Translated Product Documentation to see what is available.X


Home > Expeditor Client for Desktop > Sample: Certificate Installation
Rate this article 1 starRate this article 2 starsRate this article 3 starsRate this article 4 starsRate this article 5 stars

Sample: Certificate Installation 

expanded Abstract
collapsed Abstract
No abstract provided.
ShowTable of Contents
HideTable of Contents
  • 1 Overview
  • 2 Default Certificate Handling
  • 3 Obtaining the Certificate
  • 4 Installing the Certificate

Overview


It's often the case that developers must write secure code that interacts with secure resources such as sockets or web services. After creating code to communicate over the HTTPS protocol, developers are normally confronted with SSL errors. For example, the following error is typical.

Caused by: javax.net.ssl.SSLHandshakeException: java.security.cert.CertificateException: CWPST508W: Certificate chain root is not a trusted certificate authority.

This is resolved by importing the SSL certificate used by the external resource into the Java VM's keystore. Developers may be already familiar with tools such as IKEYMAN that allow administrators to install certificates into the cacerts keystore. But assuming a new certificate - not already in Expeditor clients - has been created, how can developers deploy the new certificate to existing clients?

Default Certificate Handling


If the code is using the javax.net.ssl.HttpsURLConnection class, which is wrapped by the Expeditor client, the following message may be seen.



In some scenarios, users can elect to install the certificate themselves. For other scenarios such as web services or custom HTTPS code, the certificate may need to be added to the keystore prior to code execution.

Obtaining the Certificate


Other than having the certificate on file, the easiest way to obtain a certificate is by accessing the resource in a browser and exporting the certificate. Do the following.
  1. In the Firefox we browser, access the resource over the web using the HTTPS URL. Firefox will prompt you to make an exception provided the certificate does not already exist in the browser.
  2. Click "Add security exception" and the "Get Certificate" button.
  3. Click the "View" button to access the certificate.
  4. Finally click the "Export" button on the "Details" tab.
  5. Save the file as an X.509 Certificate (PEM) file.

Installing the Certificate


Now that you have a certificate, the file can be added to the root folder of a plugin. Using the plugin's Activator as an entry point, the following code illustrates how one might deliver the certificate via a plugin and have the plugin complete the installation.

 public void start(BundleContext context) throws Exception {
	super.start(context);
	plugin = this;

	// get the certificate file from this plugin
	String certFile = FileLocator.getBundleFile(context.getBundle())
			.toString()
			+ File.separator + "certificate.crt";

	System.out.println("Installing " + certFile);

	if (SecurePlatform.isEnabled() && SecurePlatform.isLoggedIn()) {
		// obtain the KeyStore
		KeyStore ks = SecurePlatform.getKeyStore();
		int ksSize = ks.size(); // current number of certs

		// create a certificate
		CertificateFactory fac = CertificateFactory.getInstance("X509");
		Certificate cert = fac.generateCertificate(new FileInputStream(
				certFile));
		ks.setCertificateEntry("entrust", cert); // add the cert

		// save the new keystore
		File file = new File(SecurePlatform.getKeyStoreUrl().getFile());
		SecurePlatform.getKeyStore().store(new FileOutputStream(file),
				SecurePlatform.getPBEKeySpec().getPassword());

		// check if the certificate was added
		if (SecurePlatform.getKeyStore().size() == ksSize + 1) {
			System.out.println("Successfully added certificate");
		} else {
			System.err.println("Failed to add certificate");
		}
	} else {
		System.err
				.println("Verify that the platform is running and currently logged in");
	}
}


Be mindful that the reference to the certificate is through the File handle. Deployers should add the plugin to a feature and ensure the "Unpack the plug-in archive after installation" check box on the "Plug-ins" tab is selected. If not done, the plugin will be compressed as a JAR and the certificate file unavailable. The code also assumes that it is run after the platform has been logged in (presumably by the user or via SSO). Accommodations should be made to start the plugin after this event has occurred.

expanded Article information
collapsed Article information
Category:
Expeditor Client for Desktop
Tags:
samples

This Version: Version 5 May 4, 2011 11:40:22 AM by Van Staub  IBMer

expanded Attachments (0)
collapsed Attachments (0)

 


expanded Versions (5)
collapsed Versions (5)
Version Comparison     
Version Date Changed by               Summary of changes
This version (5) May 4, 2011 11:40:22 AM Van Staub  
4 May 4, 2011 11:26:13 AM Van Staub  
3 May 4, 2011 11:25:40 AM Van Staub  
2 May 4, 2011 11:13:49 AM Van Staub  
1 May 4, 2011 10:47:27 AM Van Staub  
expanded Comments (0)
collapsed Comments (0)
Copy and paste this wiki markup to link to this article from another article in this wiki.
Go ElsewhereStay ConnectedSubscribe to RSSHelpAbout
  • All Lotus and WebSphere Portal wikis
  • IBM developerWorks
  • IBM Software support
  • IBM Social Business User Experience Blog
  • IBMSocialBizUX on Twitter
  • IBMSocialBizUX on Facebook
  • Lotus product forums
  • IBM Social Business UX blog
  • IBM Collaboration Solutions
  • Recently added feedRecently added
  • Recently edited feedRecently edited
  • Recently added comments feedRecently Added Comments
  • Wiki Help
  • Forgot user name/password
  • Wiki design feedback
  • Content feedback
  • About the wiki
  • About IBM
  • Privacy
  • Contact IBM
  • IBM Terms of use
  • Wiki terms of use