cancel
Showing results for 
Search instead for 
Did you mean: 

Client certificate Authentication HTTP call with groovy script

ErikDM
Explorer
0 Kudos

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;
}

Accepted Solutions (0)

Answers (1)

Answers (1)

0 Kudos

Got the same issue with you. I am implementing OAuth2 client credential not knowing how to do it in groovy script, wondering if you have sort it out Erik?