How to register a certificate in Usbkey to a Windows system

Source: Internet
Author: User

This article describes how to use the Microsoft CAPI interface to complete the registration of a certificate in Usbkey to a Windows system.

(1) Gets the CSP handle.

CryptAcquireContext (
"Entersafe Et199auto CSP V1.0",

(2) To get the key handle inside the Usbkey, note that the type of the key inside the lock is the signature key (At_signature) or the Exchange key (At_keyexchange).


(3) Obtain the certificate data (only the certificate information data, not including the private key), at this time can be called two times, first obtain the length of the certificate data, allocate space, and then called again.

CryptGetKeyParam (Hkeycapi, Kp_certificate, Pbcert, &dwcertlen, 0)

(4) Create CERT_CONTEXT structure

Pcertcontext = CertCreateCertificateContext (
pkcs_7_asn_encoding | X509_asn_encoding,

(5) Open My store, this is the area where the "personal" certificate is stored in the Windows system.

Hsysstore = CertOpenStore (
L "MY");

(6) Set the certificate context properties. You declare the CRYPT_KEY_PROV_INFO structure first.

Crypt_key_prov_info Ckpi = {0};

Ckpi.pwszprovname = L "Entersafe et199auto CSP V1.0";
Ckpi.pwszcontainername = Pbwidecontainer;
Ckpi.dwprovtype = Prov_rsa_full;
Ckpi.dwkeyspec = At_keyexchange;
Ckpi.dwflags = cert_key_context_prop_id;
Ckpi.cprovparam = 0;
Ckpi.rgprovparam = NULL;

Certsetcertificatecontextproperty (
cert_key_prov_info_prop_id, Cert_store_no_crypt_release_flag,

(7) Register the certificate with the Windows system.

Certaddcertificatecontexttostore (

(8) Releases the CSP handle.

CryptReleaseContext (htokenprov,0)

The above steps allow you to register the certificate in Et199auto with the Windows system. Can we be in IE? Internet Options? What is the certificate? Individual below to view the certificate in Et199auto.

How to register a certificate in Usbkey to a Windows system

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.