Hello, I am using Azure Function (Operating System: Windows, Java) as a client to read emails from a secured mailbox (Using the JavaMail library and IMAP protocol). This mailbox needs SSL certificate authentication. I have Public Key Certificate (.cer) which I have added to Certificates in Function App settings as follows:
I have added the Thumbprint generated while adding a certificate to the function app configuration as WEBSITE_LOAD_CERIFICATES and WEBSITE_LOAD_ROOT_CERIFICATE.
I believed the above setting will allow the function app to access the public key certificate directly but I am getting the following error.
PKIX path building failed: sun.security.provider.certpath.SunCertPathBuilderException: unable to find valid certification path to requested target
I tried to add a certificate to cacert available at location JAVA_HOME\ lib\ Security using an Advance Tool available in Azure Function (KUDU) using keytool in CMD using below command:
keytool -import -alias aliasForKey -keystore "{Java-Home}/lib/security/cacerts" -storepass changeit -keypass changeit -file C:/temp/publickey.cer -noprompt
But seems like it needs admin rights to edit this file so that also didn't work for me.
What can be the possible solution for accessing seured mailbox from Azure Function (Java)? How can we configure the Azure function app to fetch emails from secured mailbox.
Any help would be appreciated, Thanks
Jitesh