Attach Client Certificate in Java Action for Rest Call

Hello, Our application is deployed in Azure Private cloud and we have a java action which makes a rest call to an End Point that requires a Client Certificate. Since we use Custom Java for rest call and app is deployed in Private server, certificate is not attached to the requests automatically. Is there a way to attach the client certificate in the java action manually i.e. using any Mendix core library method (getClientCertificates) or other Java libraries?  This is how our Custom Java looks like:    // BEGIN USER CODE         final StringBuilder result = new StringBuilder();         try {                         final HttpClient client = HttpClientBuilder.create().build();             final HttpPost post = new HttpPost(path);             // add header             post.setHeader("Consumer-Id", "xyz");             post.setHeader("X509-OU", "xyz");             post.setHeader("X509v3-SAN2", "xyz");             post.setHeader("X509v3-SAN", "xyz");                          // post.setHeader("Content-Type", "application/json");             // add form-data             final MultipartEntityBuilder builder = MultipartEntityBuilder.create();             InputStream documentRequestInputStream = Core.getFileDocumentContent(getContext(), __documentRequest);             InputStream contentInputStream = Core.getFileDocumentContent(getContext(), __content);             builder.addBinaryBody("documentRequest", documentRequestInputStream, ContentType.MULTIPART_FORM_DATA, documentRequest.getName());             builder.addBinaryBody("content", contentInputStream, ContentType.MULTIPART_FORM_DATA, content.getName());                                                        builder.setCharset(StandardCharsets.UTF_8);             post.setEntity(;             final HttpResponse response = client.execute(post);             int statusCode = response.getStatusLine().getStatusCode();                          Core.getLogger("EventsHandler").info("Response Code: " + response.getStatusLine().getStatusCode());             final BufferedReader rd = new BufferedReader(new InputStreamReader(response.getEntity().getContent()));             String line = "";             while ((line = rd.readLine()) != null) {                 result.append(line);             }             Core.getLogger("EventsHandler").info(result.toString());             if (statusCode != 201 && statusCode != 200) {                 throw new Exception(result.toString());             }             return result.toString();         } catch (Exception e) {                          throw new CoreException(result.toString());         }         // END USER CODE
1 answers

Hey Hamza,


This stumped me for a while as well as I tried to implement similar to you however you don't need to do any certificate work if you use Core.http() to make your requests.


import com.mendix.core.Core;

import com.mendix.http.HttpHeader;

import com.mendix.http.HttpMethod;

import com.mendix.http.HttpResponse;


I can't share the exact code but hopefully this is enough to help



Any questions just ask.