Dashboard > Mule FAQ - Open Source ESB and Integration Platform > ... > Frequently Asked Questions (FAQ) > How to invoke an HTTPS page
  Mule FAQ - Open Source ESB and Integration Platform Log In | Sign Up   View a printable version of the current page.  
  How to invoke an HTTPS page

Added by Kynan Fraser , last edited by Kynan Fraser on Jul 19, 2007
Labels: 
(None)

First you need to setup your keystore. Do this by retrieving the certificate from the server. A command like below will do:

$: openssl s_client -connect server.domain.name:serverport

Resulting in:

CONNECTED(00000003)
...

Certificate chain
...

Server certificate
----BEGIN CERTIFICATE----
MIIFVzCCBD+gAwIBAgIQL7PlEYd/8qFbL0TJcWayKTANBgkqhkiG9w0BAQUFADCB
lzELMAkGA1UEBhMCVVMxCzAJBgNVBAgTAlVUMRcwFQYDVQQHEw5TYWx0IExha2Ug
Q2l0eTEeMBwGA1UEChMVVGhlIFVTRVJUUlVTVCBOZXR3b3JrMSEwHwYDVQQLExho
dHRwOi8vd3d3LnVzZXJ0cnVzdC5jb20xHzAdBgNVBAMTFlVUTi1VU0VSRmlyc3Qt
SGFyZHdhcmUwHhcNMDcwNDE4MDAwMDAwWhcNMDkwNDE3MjM1OTU5WjCB1DELMAkG
A1UEBhMCQVUxDTALBgNVBBETBDIwNjAxDDAKBgNVBAgTA05TVzEVMBMGA1UEBxMM
Tm9ydGggU3lkbmV5MRgwFgYDVQQJEw8yNDUgUGFjaWZpYyBId3kxEDAOBgNVBAkT
B0xldmVsIDExKDAmBgNVBAoTH0N1c3RvbVdhcmUgQXNpYSBQYWNpZmljIFB0eSBM
dGQxGjAYBgNVBAsTEUNvbW9kbyBJbnN0YW50U1NMMR8wHQYDVQQDExZzdXBwb3J0
LmN1c3RvbXdhcmUubmV0MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQCod0Pc
JgtDnVP9QfXa9JCvZOXo9/SEV1wuVskqshhpjV3E0CY+cmN9rer+xVmiTG0i6vJJ
DknaF20xFnTN6CXG2EV8MwCj1fSc07i0IcmcUkep6ldIfdVEYwk/a5T1yM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qLvQXS5E
----END CERTIFICATE----
...


SSL handshake has read 1903 bytes and written 340 bytes

New, TLSv1/SSLv3, Cipher is DHE-RSA-AES256-SHA
Server public key is 1024 bit
Compression: NONE
Expansion: NONE

Cut and paste the certificate, (just the certificate - including BEGIN and END lines) into a local file.

Then import the certificate using the keytool program which is distributed with Java. You will be prompted for a password.

$: keytool -import -alias company.domain.name -keystore /path/to/yourkeystorefile -file filename

This will create the file: yourkeystorefile. With the certificate set as trusted.

You then need to make this keystore available to your Mule configuration at runtime (eg. in your classpath).

Setup your Mule configuration with an HTTPS connector defined as below:

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE mule-configuration PUBLIC "-//MuleSource //DTD mule-configuration XML V1.0//EN" "http://mule.mulesource.org/dtds/mule-configuration.dtd">
<mule-configuration id="https_demo" version="1.0">
	
	<connector name="HttpsConnector"
		className="org.mule.providers.http.HttpsConnector">
		<properties>
		<property name="keyStore"
				value="mykey" />
			<property name="keyPassword" value="password" />
			<property name="storePassword" value="password" />
			<property name="trustStore"
				value="mykey" />
			<property name="trustStorePassword" value="password" />		
		</properties>
	</connector>
	
	<!-- Model and Descriptor definitions -->
	<model name="sample_model">
		<mule-descriptor name="httpsinvoke"
			implementation="org.mule.components.simple.BridgeComponent">
			<inbound-router>
				<endpoint address="stream://System.in" />
			</inbound-router>

			<outbound-router>
				<router
					className="org.mule.routing.outbound.ChainingRouter">
					<endpoint
						address="https://company.domain.name:port/uri"
						connector="HttpsConnector" />

					<endpoint address="vm://handle" />
				</router>
			</outbound-router>
		</mule-descriptor>

		<mule-descriptor name="HandleResult"
			implementation="org.mule.components.simple.EchoComponent">
			<inbound-router>
				<endpoint address="vm://handle" />
			</inbound-router>
		</mule-descriptor>
	</model>
</mule-configuration>

Your component will receive the HTTPResponse object returned by your invocation.

External sources:
Set up the keystore
Set up the HTTPS connector

Copyright(c) CustomWare Asia Pacific Pty Ltd
Powered by Atlassian Confluence 2.7.3, the Enterprise Wiki. Bug/feature request - Atlassian news - Contact administrators