none
X509Store and WindowsService RRS feed

  • Question

  • Hello. I have added my own certificate with private key to the Personal store (via IE, how add it anotherway?).

    When i use that code:
     private X509Certificate CertFind()
        {
    
          X509Certificate cer = null;
          for (int i = 1; i < 9; i++)
          {
            X509Store store = new X509Store((StoreName) i, StoreLocation.LocalMachine);
            store.Open(OpenFlags.ReadOnly);
            cer = GetServerCert(store);
            if (cer != null)
              break;
            store.Close();
          }
          if (cer != null)
            return cer;
          for (int i = 1; i < 9; i++)
          {
            X509Store store = new X509Store((StoreName)i, StoreLocation.CurrentUser);
            store.Open(OpenFlags.ReadOnly);
            cer = GetServerCert(store);
            if (cer != null)
              break;
            store.Close();
          }
    
          return cer;
        }
    On Windows Form everything is ok. But using it in Windows Service C# retruns null. I am not able to locate my certificate. I am using brute force method to be sure that everything was searched.

    Futhermore on windows service store has less certyficates. HOW it is possible?
    • Moved by OmegaManModerator Sunday, April 26, 2009 9:32 PM (From:Visual C# General)
    • Moved by Reymarx Gereda Wednesday, April 29, 2009 1:07 PM off topic (From:Network Class Library (System.Net))
    Thursday, April 2, 2009 10:39 AM