It is important to configure certificates correctly for a provider hosted app in SharePoint website since the authentication requires communication between Azure AD, SharePoint, and our app, which is hosted on a different IIS server.
I have added this method to TokenHelper class and call it in CSOM webpart methods to trust certificates
public class TokenHelper
{
#region public methods
/// <summary>
/// Configures .Net to trust all certificates when making network
calls. This is used so that calls
/// to an https SharePoint server without a valid certificate are not
rejected. This should only be used
during
/// testing, and should never be used
in a production app.
/// </summary>
public static void TrustAllCertificates()
{
//Trust
all certificates
System.Net.ServicePointManager.ServerCertificateValidationCallback =
((sender, certificate,
chain, sslPolicyErrors) => true);
}
}
Also there are some articles which describe certificates trust configuration on a sharepoint farm
https://docs.microsoft.com/en-us/sharepoint/administration/exchange-trust-certificates-between-farms
https://docs.microsoft.com/en-us/sharepoint/dev/sp-add-ins/create-high-trust-sharepoint-add-ins
No comments:
Post a Comment