Wednesday, February 23, 2022

SharePoint provider hosted app certificate trust issues

 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/troubleshoot/sharing-and-permissions/ssl-certificate-authentication

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:

Regex Email validation in c# dot net core

 Use this regex /^_?[a-zA-Z0-9]([a-zA-Z0-9]*[._+-])*[a-zA-Z0-9_]+@(?!-)[A-Za-z0-9-]{1,63}(?<!-)(\.(?!-)[A-Za-z0-9-]{1,63}(?<!-))*\.[A-...