Skip to Content
0
Jul 29, 2020 at 07:01 AM

Client certificate Authentication HTTP call with groovy script

967 Views

Hi,

I try to do an Http call with Groovy script and following credentials:
Client Certificate Authentication & Key Pair that is stored in the CPI Keystore.

I succeed to do the call with Basic Authentication using the code below, but does not know how to do it with Client Certificate!

Can anyone help me out here?

Thanks,
Erik.

def Message processData(Message message) {
def body = message.getBody(java.lang.String) as String;
def messageLog = messageLogFactory.getMessageLog(message);

// Request
def get = new URL('<MyURL>').openConnection() as HttpURLConnection;

get.setRequestMethod('GET');
get.setRequestProperty('Authorization','Basic '+'<myUserID>:<myPassword>'.bytes.encodeBase64().toString());

def getRC = get.getResponseCode();
if(getRC.equals(200)) {
messageLog.setStringProperty( "ResponsePayload:" , getRC.toString() );
}
message.setBody(getRC);

return message;
}