SSL Error when calling Functions from Customizations

Hello,

I’m needing to call a Function method from a Customization but am hitting the following error:

Inner Exception

The underlying connection was closed: Could not establish trust relationship for the SSL/TLS secure channel.

Inner Exception

The remote certificate is invalid according to the validation procedure.

Here is my code calling my function. This is straight from the Epicor User Guide.

		string apiKey = GetAPIKey();
		var restClient = new RestClientBuilder()
		 .SetDefaultApiKey(apiKey)
		 .UseSession(this.oTrans.CoreSession)
		 .Build();

		var funcContent = new RestContent(
			new { 	
<data>
			})
	 	.SetApiKey(apiKey);
	
		var funcResponse = restClient.Function.Post("<FuncLibraryName>", "<FuncMethodName>", funcContent, published: true);

We have a self signed SSL certificate on our server, but since this is being called internally in an Epicor Customization it’s my understanding that that should be fine.

What’s even more confusing is that when I run the customization on the App server I get an “Invalid API Key” error, but when I use the same key using the alternate code provided by Epicor (below, but with correct params) I get the same SSL error as above.

var restClient = new RestClientBuilder()
 .SetAppServerUrl("https://host/ERP10")
 .SetCompanyId("Company")
 .SetDefaultApiKey(ApiKey)
 .UseBasicAuthentication("UserName", "Password")
 .Build();

SSL certification isn’t my strong suite, but everything seems to be setup how Epicor suggests. Any suggestions would be great!

That will not be fine. If this is a Dev server, you should be able to export the cert (.cer file, not the private key!), and copy it to your computer. Then right click and install the cert and place it in the Current User (not computer) Trusted Root Authority folder.

Test with your browser and the security lock should be on.

Whatever you used as a name for the cert has to match EXACTLY when calling the service.

Security Note: Anything signed on that machine will be now trusted on your login for that machine.

Thanks Mark! Thank makes sense.

So I’m guessing that means that for this to work correctly in our Prod environment we need to purchase an SSL Cert?

There are other options:

What is Active Directory Certificate Services and Why Should I Use It? (globalsign.com)