How do i create a Certificate.cer file RRS feed

  • Question

  • Can anyone point me in a direction on how to create a certificate.  Also when i create the certificate do I need to create it on the machine that will need to be authenticated by a third party?!

    Give youself a round of applause!!

    • Edited by Tryin2Bgood Wednesday, November 28, 2012 4:26 PM
    Wednesday, November 28, 2012 4:26 PM


  • Hi Tryin2Bgood,

      Welcome to MSDN Forum Support.

      I feel you can read this blog article,it has detailed manipulations about it. Creating a self-signed certificate in C#.


    • CryptAcquireContext(out providerContext, randomContainerName, null, PROV_RSA_FULL, CRYPT_NEWKEYSET)
    • CryptGenKey(providerContext, AT_KEYEXCHANGE, CRYPT_EXPORTABLE, out cryptKey)
    • CertStrToName(X509_ASN_ENCODING | PKCS_7_ASN_ENCODING, name, CERT_X500_NAME_STR, 0, dataBuffer, ref dataLength, 0)
    • cert = CreateSelfSignCertificate(providerContext, blob(dataBuffer, dataLength), 0, KeyProviderInfo(randomContainerName, PROV_RSA_FULL, AT_KEYEXCHANGE), 0, startTime, endTime, 0)
    • certificateStore = CertOpenStore("Memory", 0, 0, CERT_STORE_CREATE_NEW_FLAG, 0)
    • CertAddCertificateContextToStore(certificateStore, cert, CERT_STORE_ADD_NEW, out storeCert)
    • CertSetCertificateContextProperty(storeCert, CERT_KEY_PROV_INFO_PROP_ID, 0, KeyProviderInfo(randomContainerName, PROV_RSA_FULL, AT_KEYEXCHANGE))
    • PFXExportCertStoreEx(certificateStore, pfxBlob, password, 0, EXPORT_PRIVATE_KEYS)
    • Free everything.

      These are its steps listed in link above.


      Jason Wang

    Jason Wang [MSFT]
    MSDN Community Support | Feedback to us

    • Marked as answer by Jason Dot Wang Thursday, December 6, 2012 9:16 AM
    Friday, November 30, 2012 2:42 AM