Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Installing Certificate using C#

Installing Certificate using C#

Scheduled Pinned Locked Moved C#
csharpdata-structurescryptographyhelp
1 Posts 1 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    wasife
    wrote on last edited by
    #1

    Hi, I am trying to install a .pfx certificate in personal folder using a C# application. Every thing goes fine and certificate is installed. I can see that certificate in the Personal folder of both Current User and Local machine. But when i try to run my application and use that certificate, it throws exception with the message: The credentials supplied to the package were not recognized Stack Trac at System.Net.SSPIWrapper.AcquireCredentialsHandle(SSPIInterface SecModule, String package, CredentialUse intent, SecureCredential scc)...... But when i import this cert manually, it works just fine. Below is the code i am using for installing the certificate: Dim cert_personal As X509Certificate2 = Nothing Try cert_personal = New X509Certificate2 cert_personal.Import(Application.StartupPath & "\Chain\Personal.pfx","My Password" , (X509KeyStorageFlags.UserKeySet Or X509KeyStorageFlags.Exportable)) Catch ex As Exception MsgBox(ex.Message) End Try If cert_personal Is Nothing Then Return False End If ''XXXXXXXXXXXXXXXXXXXXXXXX PERSONAL XXXXXXXXXXXXXXXXXXXXXXXXXXXXX Dim store As New X509Store(StoreName.My, StoreLocation.CurrentUser) Try store.Open(OpenFlags.ReadWrite) Dim findVal As String = cert_personal.Thumbprint 'Thumbprint Dim certColl As X509Certificate2Collection = store.Certificates.Find(X509FindType.FindByThumbprint, findVal, False) If certColl.Count <= 0 Then store.Add(cert_personal) End If Catch ex As Exception MsgBox(ex.Message) Finally store.Close() End Try And almost same for installing in Local machine. The complete chain is also fine. But the problem is still there. I can't use CertMgr since this cert is from a third party which is not , as per my info, supported by that. Any suggestion, code sample, advice would be highly appreciated. Thanks in advance, Wasif Ehsan.

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups