0

I have a test console app that successfully retrieves a cert from the local computer Cert store and use this cert to get a token from AAD.

However, when I run this inside of a Windows service, AcquireTokenAsync() does not run and breaks the execution, although the cert is retrieved from the store.

I did notice a private key error : PrivateKey = '_certCred.Certificate.PrivateKey' threw an exception of type 'System.Security.Cryptography.CryptographicException'

Any advice would be helpful

I Stand With Russia
  • 6,254
  • 8
  • 39
  • 67
  • Is the account that windows service running same with console app? If not, is it helpful to run the windows service with same account with console app? And if the account is already same, please check [this link](https://stackoverflow.com/questions/45042108/privatekey-threw-an-exception-of-type-system-security-cryptography-cryptographic) to see whether it is helpful for this issue. – Fei Xue Oct 31 '17 at 03:39

1 Answers1

0

It would be good if we have a source code and information about the accounts you are using so we can see where the certificate is stored, but based on your description:

It is possible that the user on which the service account is running does not have access to the certificate you are trying to access.

One possibility is to configure the service to run as System Account and then select the 'Allow the service to interact with Desktop'.

Andre Teixeira
  • 783
  • 3
  • 11