- Certmgr.exe (Certificate Manager Tool)
- Syntax
- Parameters
- Remarks
- Examples
- CertMgr
- Partial list of operations, switches, and arguments
- Operations
- Switches and Arguments
- Comments
- Certmgr.exe (средство диспетчера сертификатов) Certmgr.exe (Certificate Manager Tool)
- Синтаксис Syntax
- Параметры Parameters
- Примечания Remarks
- Примеры Examples
Certmgr.exe (Certificate Manager Tool)
The Certificate Manager tool (Certmgr.exe) manages certificates, certificate trust lists (CTLs), and certificate revocation lists (CRLs).
The Certificate Manager is automatically installed with Visual Studio. To start the tool, use Visual Studio Developer Command Prompt or Visual Studio Developer PowerShell.
The Certificate Manager tool (Certmgr.exe) is a command-line utility, whereas Certificates (Certmgr.msc) is a Microsoft Management Console (MMC) snap-in. Because Certmgr.msc is usually found in the Windows System directory, entering certmgr at the command line may load the Certificates MMC snap-in even if you have opened the Developer Command Prompt for Visual Studio. This occurs because the path to the snap-in precedes the path to the Certificate Manager tool in the PATH environment variable. If you encounter this problem, you can execute Certmgr.exe commands by specifying the path to the executable.
For an overview of X.509 certificates, see Working with Certificates.
At the command prompt, type the following:
Syntax
Parameters
Argument | Description |
---|---|
sourceStorename | The certificate store that contains the existing certificates, CTLs, or CRLs to add, delete, save, or display. This can be a store file or a systems store. |
destinationStorename | The output certificate store or file. |
Option | Description |
---|---|
/add | Adds certificates, CTLs, and CRLs to a certificate store. |
/all | Adds all entries when used with /add. Deletes all entries when used with /del. Displays all entries when used without the /add or /del options. The /all option cannot be used with /put. |
/c | Adds certificates when used with /add. Deletes certificates when used with /del. Saves certificates when used with /put. Displays certificates when used without the /add, /del, or /put option. |
/CRL | Adds CRLs when used with /add. Deletes CRLs when used with /del. Saves CRLs when used with /put. Displays CRLs when used without the /add, /del, or /put option. |
/CTL | Adds CTLs when used with /add. Deletes CTLs when used with /del. Saves CTLs when used with /put. Displays CTLs when used without the /add, /del, or /put option. |
/del | Deletes certificates, CTLs, and CRLs from a certificate store. |
/e encodingType | Specifies the certificate encoding type. The default is X509_ASN_ENCODING . |
/f dwFlags | Specifies the store open flag. This is the dwFlags parameter passed to CertOpenStore. The default value is CERT_SYSTEM_STORE_CURRENT_USER. This option is considered only if the /y option is used. |
/h[elp] | Displays command syntax and options for the tool. |
/n nam | Specifies the common name of the certificate to add, delete, or save. This option can only be used with certificates; it cannot be used with CTLs or CRLs. |
/put | Saves an X.509 certificate, CTL, or CRL from a certificate store to a file. The file is saved in X.509 format. You can use the /7 option with the /put option to save the file in PKCS #7 format. The /put option must be followed by either /c, /CTL, or /CRL. The /all option cannot be used with /put. |
/r location | Identifies the registry location of the system store. This option is considered only if you specify the /s option. location must be one of the following: — currentUser indicates that the certificate store is under the HKEY_CURRENT_USER key. This is the default. |
/s | Indicates that the certificate store is a system store. If you do not specify this option, the store is considered to be a StoreFile. |
/sha1 sha1Hash | Specifies the SHA1 hash of the certificate, CTL, or CRL to add, delete, or save. |
/v | Specifies verbose mode; displays detailed information about certificates, CTLs, and CRLs. This option cannot be used with the /add, /del, or /put options. |
/y provider | Specifies the store provider name. |
/7 | Saves the destination store as a PKCS #7 object. |
/? | Displays command syntax and options for the tool. |
Remarks
Certmgr.exe performs the following basic functions:
Displays certificates, CTLs, and CRLs to the console.
Adds certificates, CTLs, and CRLs to a certificate store.
Deletes certificates, CTLs, and CRLs from a certificate store.
Saves an X.509 certificate, CTL, or CRL from a certificate store to a file.
Certmgr.exe works with two types of certificate stores: StoreFile and system store. It is not necessary to specify the type of certificate store; Certmgr.exe can identify the store type and perform the appropriate operations.
Running Certmgr.exe without specifying any options launches the certmgr.msc snap-in, which has a GUI that helps with the certificate management tasks that are also available from the command line. The GUI provides an import wizard, which copies certificates, CTLs, and CRLs from your disk to a certificate store.
You can find the names of X509Certificate stores for the sourceStorename and destinationStorename parameters by compiling and running the following code.
For more information about certificates, see Working with Certificates.
Examples
The following command displays a default system store called my with verbose output.
The following command adds all the certificates in a file called myFile.ext to a new file called newFile.ext .
The following command adds the certificate in a file named testcert.cer to the my system store.
The following command adds the certificate in a file named TrustedCert.cer to the root certificate store.
The following command saves a certificate with the common name myCert in the my system store to a file called newCert.cer .
The following command deletes all CTLs in the my system store and saves the resulting store to a file called newStore.str .
The following command saves a certificate in the my system store in the file newFile . You will be prompted to enter the certificate number from my to put in newFile .
CertMgr
CertMgr (Certmgr.exe) is a command-line CryptoAPI tool that manages certificates, certificate trust lists (CTLs), and certificate revocation lists (CRLs).
CertMgr supports a large number of switches, but this section describes only those that are relevant to managing test certificates within a certificate store.
Partial list of operations, switches, and arguments
Operations
add
Configures CertMgr to add certificates, CTLs, or CRLs from the file specified by SourceName to the certificate store specified by DestinationName.
del
Configures CertMgr to delete certificates, CTLs, or CRLs in the certificate store specified by SourceName from the certificate store specified by DestinationName. If DestinationName is not specified, SourceName will also serve as the destination store and will be modified.
put
Configures CertMgr to save certificates, CTLs, or CRLs from the certificate store specified by SourceName to a file specified by DestinationName.
none
If no command is specified, CertMgr displays all the certificates, CTLs, or CRLs in the certificate store or file specified by SourceName.
Switches and Arguments
/c
Configures CertMgr to only process certificates from the file specified by SourceName.
/CTL
Configures CertMgr to only process CTLs from the file specified by SourceName.
/CRL
Configures CertMgr to only process CRLs from the file specified by SourceName.
/s
Configures CertMgr to access the certificate store specified by SourceName or DestinationName as a system store.
/r registryLocation
Specifies the registry location of the system certificate store. The /r switch is only valid when used with the /s switch. The registryLocation argument must be either:
currentUser
Specifies the registry location HKEY_CURRENT_USER.
localMachine
Specifies the registry location HKEY_LOCAL_MACHINE.
If the /r switch is not specified along with the /s switch, currentUser is the default.
For more information about these certificate stores, see Certificate Stores.
/v
Configures CertMgr to display detailed information about certificates, CTLs, and CRLs. If this switch is not specified, CertMgr only displays brief information.
Comments
To use CertMgr, the user must be a member of the Administrators group on the system and run the command from an elevated command prompt.
For a complete list of CertMgr parameters, see the Certificate Manager Tool website.
A 32-bit version of the CertMgr tool is located in the bin\i386 folder of the WDK. A 64-bit version of the tool is located in the bin\amd64 and bin\ia64 folders of the WDK.
Certmgr.exe (средство диспетчера сертификатов) Certmgr.exe (Certificate Manager Tool)
Диспетчер сертификатов (Certmgr.exe) предназначен для управления сертификатами, списками доверия сертификатов (CTL) и списками отзыва сертификатов (CRL). The Certificate Manager tool (Certmgr.exe) manages certificates, certificate trust lists (CTLs), and certificate revocation lists (CRLs).
Диспетчер сертификатов устанавливается автоматически вместе с Visual Studio. The Certificate Manager is automatically installed with Visual Studio. Для запуска этого средства используйте Командную строку разработчика или PowerShell для разработчиков в Visual Studio. To start the tool, use Visual Studio Developer Command Prompt or Visual Studio Developer PowerShell.
Диспетчер сертификатов (Certmgr.exe) является служебной программой командной строки, в то время как сертификаты (Certmgr.msc) — это оснастка консоли управления (MMC). The Certificate Manager tool (Certmgr.exe) is a command-line utility, whereas Certificates (Certmgr.msc) is a Microsoft Management Console (MMC) snap-in. Поскольку файл Certmgr.msc обычно находится в системном каталоге Windows, при вводе certmgr в командной строке может загрузиться оснастка консоли управления (MMC) «Сертификаты», даже если открыта командная строка разработчика для Visual Studio. Because Certmgr.msc is usually found in the Windows System directory, entering certmgr at the command line may load the Certificates MMC snap-in even if you have opened the Developer Command Prompt for Visual Studio. Это происходит потому, что путь к оснастке предшествует пути к диспетчеру сертификатов в переменной среды PATH. This occurs because the path to the snap-in precedes the path to the Certificate Manager tool in the PATH environment variable. При возникновении этой проблемы команды Certmgr.exe можно выполнить, указав путь к исполняемому файлу. If you encounter this problem, you can execute Certmgr.exe commands by specifying the path to the executable.
Общие сведения о сертификатах X.509 см. в разделе Работа с сертификатами. For an overview of X.509 certificates, see Working with Certificates.
В командной строке введите следующее. At the command prompt, type the following:
Синтаксис Syntax
Параметры Parameters
Аргумент Argument | Описание Description |
---|---|
sourceStorename sourceStorename | Хранилище сертификатов, содержащее существующие сертификаты, списки доверия сертификатов (CTL) и списки отзыва сертификатов (CRL) для добавления, удаления, сохранения или отображения. The certificate store that contains the existing certificates, CTLs, or CRLs to add, delete, save, or display. Это может быть файл хранилища или хранилище систем. This can be a store file or a systems store. |
destinationStorename destinationStorename | Конечное хранилище сертификатов или файл. The output certificate store or file. |
Параметр Option | Описание: Description |
---|---|
/add /add | Добавляет сертификаты, CTL и CRL в хранилище сертификатов. Adds certificates, CTLs, and CRLs to a certificate store. |
/all /all | Добавляет все записи при использовании параметра /add. Adds all entries when used with /add. Удаляет все записи при использовании параметра /del. Отображает все записи при использовании без параметров /add или /del. Deletes all entries when used with /del. Displays all entries when used without the /add or /del options. Параметр /all нельзя использовать вместе с параметром /put. The /all option cannot be used with /put. |
/c /c | Добавляет сертификаты при использовании параметра /add. Adds certificates when used with /add. Удаляет сертификаты при использовании параметра /del. Сохраняет сертификаты при использовании параметра /put. Deletes certificates when used with /del. Saves certificates when used with /put. Отображает сертификаты при использовании без параметра /add, /del или /put. Displays certificates when used without the /add, /del, or /put option. |
/CRL /CRL | При использовании с параметром /add добавляет списки отзыва сертификатов (CRL). Adds CRLs when used with /add. При использовании с параметром /del удаляет списки отзыва сертификатов (CRL). Сохраняет списки CRL при использовании с параметром /put. Deletes CRLs when used with /del. Saves CRLs when used with /put. Отображает списки отзыва сертификатов (CRL) при использовании без параметра /add, /del или /put. Displays CRLs when used without the /add, /del, or /put option. |
/CTL /CTL | При использовании с параметром /add добавляет списки доверия сертификатов (CTL). Adds CTLs when used with /add. При использовании с параметром /del удаляет списки доверия сертификатов (CTL). Сохраняет списки CTL при использовании с параметром /put. Deletes CTLs when used with /del. Saves CTLs when used with /put. Отображает списки доверия сертификатов (CTL) при использовании без параметра /add, /del или /put. Displays CTLs when used without the /add, /del, or /put option. |
/del /del | Удаляет сертификаты, CTL и CRL из хранилища сертификатов. Deletes certificates, CTLs, and CRLs from a certificate store. |
/e encodingType /e encodingType | Указывает тип шифрования сертификата. Specifies the certificate encoding type. Значение по умолчанию — X509_ASN_ENCODING . The default is X509_ASN_ENCODING . |
/f dwFlags /f dwFlags | Задает открытый флаг хранилища. Specifies the store open flag. Это параметр dwFlags, передаваемый методу CertOpenStore. This is the dwFlags parameter passed to CertOpenStore. По умолчанию используется значение CERT_SYSTEM_STORE_CURRENT_USER. The default value is CERT_SYSTEM_STORE_CURRENT_USER. Этот параметр обрабатывается, только если задан параметр /y. This option is considered only if the /y option is used. |
/h[elp] /h[elp] | Отображает синтаксис команд и параметров программы. Displays command syntax and options for the tool. |
/n nam /n nam | Задает общее имя добавляемого, удаляемого или сохраняемого сертификата. Specifies the common name of the certificate to add, delete, or save. Этот параметр может применяться только для сертификатов, его нельзя задавать для CTL и CRL. This option can only be used with certificates; it cannot be used with CTLs or CRLs. |
/put /put | Сохраняет в файл сертификат X.509, CTL или CRL из хранилища сертификатов. Saves an X.509 certificate, CTL, or CRL from a certificate store to a file. Файл сохраняется в формате X.509. The file is saved in X.509 format. Чтобы сохранить файл в формате PKCS #7, можно использовать параметр /7 с параметром /put. You can use the /7 option with the /put option to save the file in PKCS #7 format. За параметром /put должен следовать параметр /c, /CTL или /CRL. The /put option must be followed by either /c, /CTL, or /CRL. Параметр /all нельзя использовать вместе с параметром /put. The /all option cannot be used with /put. |
/r location /r location | Указывает расположение системного хранилища в реестре. Identifies the registry location of the system store. Этот параметр обрабатывается, только если задан параметр /s. This option is considered only if you specify the /s option. Параметр location должен иметь одно из следующих значений. location must be one of the following: — currentUser означает, что хранилище сертификатов находится в разделе HKEY_CURRENT_USER. — currentUser indicates that the certificate store is under the HKEY_CURRENT_USER key. Это значение по умолчанию. This is the default. |
/s /s | Означает, что хранилище сертификатов является системным. Indicates that the certificate store is a system store. Если этот параметр не задан, хранилищем считается StoreFile. If you do not specify this option, the store is considered to be a StoreFile. |
/sha1 sha1Hash /sha1 sha1Hash | Задает хэш SHA1 добавляемого, удаляемого или сохраняемого сертификата, CTL или CRL. Specifies the SHA1 hash of the certificate, CTL, or CRL to add, delete, or save. |
/v /v | Включает отображение подробных сведений о сертификатах, CTL и CRL. Specifies verbose mode; displays detailed information about certificates, CTLs, and CRLs. Этот параметр невозможно использовать с параметрами /add, /del или /put. This option cannot be used with the /add, /del, or /put options. |
/y provider /y provider | Задает имя поставщика хранилища. Specifies the store provider name. |
/7 /7 | Сохраняет конечное хранилище как объект PKCS #7. Saves the destination store as a PKCS #7 object. |
/? /? | Отображает синтаксис команд и параметров программы. Displays command syntax and options for the tool. |
Примечания Remarks
Основные функции программы Certmgr.exe. Certmgr.exe performs the following basic functions:
Отображение сведений о сертификатах, CTL и CRL на консоли. Displays certificates, CTLs, and CRLs to the console.
Добавляет сертификаты, CTL и CRL в хранилище сертификатов. Adds certificates, CTLs, and CRLs to a certificate store.
Удаляет сертификаты, CTL и CRL из хранилища сертификатов. Deletes certificates, CTLs, and CRLs from a certificate store.
Сохраняет в файл сертификат X.509, CTL или CRL из хранилища сертификатов. Saves an X.509 certificate, CTL, or CRL from a certificate store to a file.
Программа Certmgr.exe работает с двумя типами хранилищ сертификатов: системным и StoreFile. Certmgr.exe works with two types of certificate stores: StoreFile and system store. Указывать тип хранилища необязательно, поскольку программа Cedrtmgr.exe может автоматически определить тип хранилища и выполнить соответствующие действия. It is not necessary to specify the type of certificate store; Certmgr.exe can identify the store type and perform the appropriate operations.
При запуске программы Certmgr.exe без параметров выполняется оснастка «certmgr.msc» с графическим интерфейсом пользователя, облегчающим управление сертификатами, что также можно сделать из командной строки. Running Certmgr.exe without specifying any options launches the certmgr.msc snap-in, which has a GUI that helps with the certificate management tasks that are also available from the command line. В графическом интерфейсе пользователя имеется мастер импорта, копирующий сертификаты, CTL и CRL с диска в хранилище сертификатов. The GUI provides an import wizard, which copies certificates, CTLs, and CRLs from your disk to a certificate store.
Чтобы найти имена хранилищ X509Certificate для параметров sourceStorename и destinationStorename , можно скомпилировать и выполнить следующий код. You can find the names of X509Certificate stores for the sourceStorename and destinationStorename parameters by compiling and running the following code.
Дополнительные сведения см. в разделе Работа с сертификатами. For more information about certificates, see Working with Certificates.
Примеры Examples
Следующая команда выводит подробные сведения о содержимом системного хранилища my , используемого по умолчанию. The following command displays a default system store called my with verbose output.
Следующая команда добавляет все сертификаты из файла myFile.ext в новый файл newFile.ext . The following command adds all the certificates in a file called myFile.ext to a new file called newFile.ext .
Следующая команда добавляет сертификат в файле testcert.cer в хранилище системы my . The following command adds the certificate in a file named testcert.cer to the my system store.
Следующая команда добавляет сертификат в файле TrustedCert.cer в хранилище корневых сертификатов. The following command adds the certificate in a file named TrustedCert.cer to the root certificate store.
Следующая команда сохраняет сертификат с общим именем myCert в системном хранилище my в файл newCert.cer . The following command saves a certificate with the common name myCert in the my system store to a file called newCert.cer .
Следующая команда удаляет все CTL из системного хранилища my и сохраняет полученное хранилище в файл newStore.str . The following command deletes all CTLs in the my system store and saves the resulting store to a file called newStore.str .
Следующая команда сохраняет сертификат в системном хранилище my в файл newFile . The following command saves a certificate in the my system store in the file newFile . Программа запросит у пользователя номер сертификата из хранилища my , который следует поместить в файл newFile . You will be prompted to enter the certificate number from my to put in newFile .