How to fix "The certificate does not have a private key"?
Issue Description: When using Application ID and Certificate authentication from Office 365 Scope, the following error is thrown when trying to authenticate
Full Error In Text:
RemoteException wrapping Microsoft-GraphServiceException: Code: generalExcepti0n Message: An error occurred sending the request. > RemoteException wrapping Microsoft.Identity.CIient.MsaICIientException: The certificate certificate does not have a private key. at Microsoft.ldentity.ClientConfidentialCIientApplicationBuilder.WithCertificate(X509Certificate2 certificate) at UiPathSharedAuthenticationMicrosoftServicesMsalLogonServiceGetBuilderFromCertificate(OAuthDataOptions oauth) at UiPathShared.Authentication.MicrOSOft.Services.MsaILogonService.GetConfidentiaIAppIication(OAuthDataOptions oauth) at UiPathSharedAuthenticationMicrosoftServicesMsalLogonService.AuthenticatelntemalAsync(OAuthDataOptions oauth, CancellationToken cancellation Token)
Root Cause:
- The base64 representation of your certificate is incorrect
- The certificate wasn't properly created, therefore does not have a private key.
Resolution:
- The base64 representation of your certificate is incorrect
- To ensure that the conversion is done right, use the following VB expression to convert the .pfx certificate to base64
convert.ToBase64String(System.IO.File.ReadAllBytes(“YourCertPath"))
- The certificate was not properly created, therefore does not have a private key
- Check with the certificate publisher. Additionally, Create your own self-signed certificate to authenticate and check if the issue persists. (Ensure to also export the public certificate and its private key).