Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Audience management API: The RSA key container could not be opened

This is a follow up question to this one: Outbound E-mail Profile API: Get list of e-mailaddresses

I'm writing a simple example to explore the Audience Management API. All the code I have is here.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Tridion.AudienceManagement.API;

namespace OEPasswordEncrypt
{
    class Program
    {
        static void Main(string[] args)
        {
            StaticAddressBook importAddressBook = new StaticAddressBook(new UserContext());
        }
    }
}

The error I'm getting when I run this on the CM server is this:

Unhandled Exception: System.TypeInitializationException: The type initializer for 'Tridion.AudienceManagement.DomainModel.Utilities.Configuration' threw an exception. ---> Tridion.AudienceManagement.DomainModel.Exceptions.LocalizableConfiguationErrorsException: Loading of the configuration failed. ---> System.Configuration.ConfigurationErrorsException: The RSA key container could not be opened.
   at System.Configuration.RsaProtectedConfigurationProvider.ThrowBetterException(Boolean keyMustExist)
   at System.Configuration.RsaProtectedConfigurationProvider.GetCryptoServiceProvider(Boolean exportable, Boolean keyMustExist)
   at System.Configuration.RsaProtectedConfigurationProvider.Decrypt(XmlNode encryptedNode)
   at Tridion.AudienceManagement.DomainModel.Utilities.ConfigurationEncryption.TraverseAndProcessChildren(Dictionary`2 protectedConfigurationProviders, XmlNodenode)
   at Tridion.AudienceManagement.DomainModel.Utilities.ConfigurationEncryption.DecryptConfiguration(XmlDocument rawConfiguration)
   at Tridion.AudienceManagement.DomainModel.Utilities.Configuration.Reload()
   --- End of inner exception stack trace ---
   at Tridion.AudienceManagement.DomainModel.Utilities.Configuration.Reload()
   at Tridion.AudienceManagement.DomainModel.Utilities.Configuration..cctor()
   --- End of inner exception stack trace ---
   at Tridion.AudienceManagement.DomainModel.Utilities.Configuration.get_LogFolder()
   at Tridion.AudienceManagement.DomainModel.Utilities.Logger.AssertValidLogFolder()
   at Tridion.AudienceManagement.DomainModel.Utilities.Logger.WriteLine(LogLevel logLevel, String message, Object[] objects)
   at Tridion.AudienceManagement.DomainModel.Utilities.Logger.WriteLine(LogLevel logLevel, String message)
   at Tridion.AudienceManagement.DomainModel.Utilities.Logger.Info(String message)
   at Tridion.AudienceManagement.DomainModel.ServiceClient.ContentManagerClient.LogBindingInfo(Exception ex)
   at Tridion.AudienceManagement.DomainModel.ServiceClient.ContentManagerClient.GetConfiguredCoreService()
   at Tridion.AudienceManagement.DomainModel.ServiceClient.ContentManagerClient.GetClient(UserContext userContext, UserData& userData)
   at Tridion.AudienceManagement.DomainModel.ServiceClient.ContentManagerClient.LoadCurrentUser(UserContext userContext, String userDataXml)
   at Tridion.AudienceManagement.DomainModel.UserContext..ctor(String trusteeName)
   at Tridion.AudienceManagement.DomainModel.UserContext..ctor()
   at Tridion.AudienceManagement.API.UserContext..ctor()
   at OEPasswordEncrypt.Program.Main(String[] args) in c:\users\kaht\documents\visual studio 2010\Projects\OEPasswordEncrypt\OEPasswordEncrypt\Program.cs:line 13

I've already tried running aspnet_regiis TridionRsaKeyContainer with my own username, but that tells me the RSA key container doesn't exist.

like image 731
Kah Tang Avatar asked Oct 07 '22 21:10

Kah Tang


1 Answers

Try running the following command:

aspnet_regiis -pa "TridionRsaKeyContainer" "User_Name"

like image 169
Bappi Avatar answered Oct 13 '22 10:10

Bappi