Failed to perstently Import SIGNATURE KEY pair into the key container RRS feed

  • Question

  • using System; 
    using System.IO; 
    using System.Security.Cryptography; 
    public class cspimp  
            public static void Main(string[] args) 
                    if (args.Length!=2) { 
                            Console.WriteLine ("Usage:cspimp <key container> <signature xml> "); 
                    StreamReader sr1 = new StreamReader (args[1]); 
                    string sigXml = sr1.ReadToEnd(); 
                    sigXmlsigXml = sigXml.Trim(); 
                    CspParameters cp = new CspParameters(1, "Microsoft Base Cryptographic Provider v1.0"); 
                    cp.KeyContainerName = args[0]; 
                    cp.Flags = CspProviderFlags.UseMachineKeyStore; 
                    cp.KeyNumber = (int) KeyNumber.Signature; 
                    RSACryptoServiceProvider rsa_sig = new RSACryptoServiceProvider(cp); 
                    rsa_sig.PersistKeyInCsp = true
    Hi, all

    I’m working with “Microsoft Base Cryptographic Server v1.0” and want to persistently import SIGNATURE key pair (private/public) of another key container into the existing key container. 

    Import of EXCHANGE key pair worked without any problem but for some reason this wouldn’t work for the case of SIGNATURE key pair. In case of SIGNATURE key pairs, update key lasted only for process's life time.

    In above table,  I put the snippet of code that I tested to import the keyblob (in XML format) 

    Please, take a look at this code 
    Thanks for your help in advance. 

    Regards, Kangkook

    • Edited by Jikk Tuesday, August 12, 2008 5:04 AM reformat the source
    Tuesday, August 12, 2008 4:51 AM

All replies