httpClientLib - Send request with certificate authentication


How can I translate this curl request to httpClient request by use of httpClientLib?
curl “” --key private.key --cert certname.crt -H “Content-type: application/json”

The documentation for httpClientLib:!/module-lib_xp_http-client.html doesn’t mention about auth with certificate and key.

Thanks for any help.


I understand you are trying to use a client certificate for authenticating with HTTPS. This is currently not supported in the http-client library.

It could be a feature request to support client certificates. But we would need some server we can use for testing it.
The library uses Java OkHttp under the hood. I have to check if client cert is supported in OkHttp.

Ok, this is currently not supported in the http-client library.
Is there any another way to make it work in enonic XP 6.8 ? maybe with custom Java code?

You can call Java code from JavaScript, either creating a library or putting the code in your own app. The code is the same in both cases.
You can see an example of how to call Java from JavaScript in this library:

Regarding the HTTPS request with certificate auth in Java, it looks like it should be something like this:

I suggest first creating a simple Java main class and make it work in Java, then move it to a library. If you find issues with the integration to JavaScript you can ask in this forum and we’ll try to help.