Hi,
I have an application that is connecting to Google API and is working fine from my development computer.
I've made a Console Application to try to debug my problem.
public void Connect() {
if (certificate != null)
{
ServiceAccountCredential credential = new ServiceAccountCredential(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
User = Configuration.googleApps.impersonationUser,
Scopes = new[] { DirectoryService.Scope.AdminDirectoryUser ,
DirectoryService.Scope.AdminDirectoryGroup
}
}.FromCertificate(certificate));
.....
}
}
When I run this application on another machine (Windows Server 2012), I have the following exception when the ServiceAccountCredential instanciate :
Key not valid for use in specified state.
Any idea ?
Thanks in advance.
See the end of this message for details on invoking
just-in-time (JIT) debugging instead of this dialog box.
************** Exception Text **************
System.Security.Cryptography.CryptographicException: Key not valid for use in specified state.
at System.Security.Cryptography.CryptographicException.ThrowCryptographicException(Int32 hr)
at System.Security.Cryptography.Utils.ExportCspBlob(SafeKeyHandle hKey, Int32 blobType, ObjectHandleOnStack retBlob)
at System.Security.Cryptography.Utils.ExportCspBlobHelper(Boolean includePrivateParameters, CspParameters parameters, SafeKeyHandle safeKeyHandle)
at System.Security.Cryptography.RSACryptoServiceProvider.ExportCspBlob(Boolean includePrivateParameters)
at Google.Apis.Auth.OAuth2.ServiceAccountCredential.Initializer.FromCertificate(X509Certificate2 certificate) in c:\code\
google.com\google-api-dotnet-client\default\Tools\Google.Apis.Release\bin\Debug\test\default\Src\GoogleApis.Auth.DotNet4\OAuth2\ServiceAccountCredential.cs:line 80
at GoogleAppSync.GoogleConnector.Connect() in d:\Mes Documents\InternalTools\MinervaDirectorySync\GoogleAppsSync\GAppsSync.cs:line 30