Free Support Forum -

Microsoft Word Document Mail Merge API Call failing in SalesForce using Aspose.Words REST API due to certificate error

We are not able to print anything while making a callout from Salesforce.

The request for mailMergeFieldNames FAILS WITH CERT ERROR.

Seems like it cannot find a valid certificate or certificate is not included
Can you please rectify this ASAP ?

This is the log from the request

20:59:47.110 (110353222)|CALLOUT_REQUEST|[1347]|System.HttpRequest[Endpoint=, Method=GET]
20:59:47.413 (413011811)|CALLOUT_REQUEST|[1347]|System.HttpRequest retrying request in response to handshake failure: PKIX path building failed: unable to find valid certification path to requested target
20:59:47.647 (647566897)|EXCEPTION_THROWN|[1347]|System.CalloutException: PKIX path building failed: unable to find valid certification path to requested target

Hi Sunil,

Certificate issue has been fixed. Can you please try again and confirm if the issue has been fixed at your end as well?

Best Regards,

I sent you an email separately on this with the callout link. This issue is happening from salesforce callout.

Here’s a link that might be helpful:

Sent another email with sample code

Any update?


Sorry, we were unable to reproduce this issue at our end before because there was no such issue in .NET or PHP.

Looks like this issue is specific to Salesforce. We are working to resolve this issue as soon as possible. You will be updated as soon as it is resolved.

Sorry for the inconvenience.

Best Regards,

Hi Sunil,

Our team is fixing this issue. In the meantime, can you please compare the following Sign method with your Sign method and use this method if your copy is different?

public static String Sign(String data) {

String HMAC_SHA1 = 'HmacSHA1';

try {

data = data.replace(' ', '%20');

URL url = new URL(data);

String path = url.getPath();

path = path.replace(' ', '%20');

<?xml:namespace prefix = "o" ns = "urn:schemas-microsoft-com:office:office" />

// Remove final slash here as it can be added automatically.

path = path.removeEnd('/');

String filePart = url.getPath() + (url.getQuery() == null ? '?'+ 'appSID=' + AsposeCloudApp.AppSID : '?' + url.getQuery()+ '&appSID=' + AsposeCloudApp.AppSID);

url = new URL(url.getProtocol(), url.getHost(), url.getPort(), filePart);

// compute the hmac on input data bytes

Blob mac = Crypto.generateMac('hmacSHA1', Blob.valueOf(filePart), EncodingUtil.base64Decode(AsposeCloudApp.AppKey));

String base64 = EncodingUtil.base64Encode(mac);

system.debug('base64: ' + base64);

// Remove invalid symbols.

String result = base64.replace('+', '-').replace('/', '_');

system.debug('signature: ' + result);

String encodedUrl = url.toExternalForm() + '&signature=' + result;

system.debug('full URL: ' + encodedUrl);

return encodedUrl;

} catch (Exception ex) {


return null;



Best Regards,

It seems ok to me.

I believe there was something fixed from your end which fixed the issue. We are able to print documents at the moment .

Thanks for the quick fix

Hi Sunil,

Yes, there was some problem with the SSL certificate. It was fixed.

Sorry for the inconvenience caused by this issue.

Best Regards,

Hi @muhammad.ijaz,

I have the same issue (“PKIX path building failed: unable to find valid certification path to requested target”) with a server which is connected to Salesforce and I’m not able to find into the web the solution to fix the server with the good certificate. I know that it’s been a long time since you made this post but if you remember the solution you put in place for the SSL certificate, I’m a taker.

Thanks you,
Best Regards,


We are sorry for your inconvenience. I am afraid we have not received any such complaint from any other customer. We will appreciate it if you please confirm which API you are using and API call details as well. We will look into it and will guide you accordingly.