Re: Как работать с информацией о сертификате, C_EX_GetCertificateInfoText?

MarErm,

C помощью PKCS#11 удастся получить данные о сертификате, если соответствующие сертификату открытый и закрытый ключи -- неизвлекаемые в формате аппаратного криптопровайдера Рутокен.

Скажите, пожалуйста, как вы генерируете ключи и сертификаты на токене.

У вас текущий сертификат отображается на https://ra.rutoken.ru/?

Если текущие ключи и сертификат не отображается - то скорее всего у вас контейнеры в формате КрипроПРО CSP.

Воспользуйтесь примером перечисления контейнеров КриптоПро в Рутокен SDK: <sdk>\CryptoAPI\CryptoProCSP\Read-GOST34.10-2012-256

(2019-11-11 13:17:52 отредактировано MarErm)

Re: Как работать с информацией о сертификате, C_EX_GetCertificateInfoText?

Павел Анфимов пишет:

MarErm,

C помощью PKCS#11 удастся получить данные о сертификате, если соответствующие сертификату открытый и закрытый ключи -- неизвлекаемые в формате аппаратного криптопровайдера Рутокен.

Скажите, пожалуйста, как вы генерируете ключи и сертификаты на токене.

У вас текущий сертификат отображается на https://ra.rutoken.ru/?

Если текущие ключи и сертификат не отображается - то скорее всего у вас контейнеры в формате КрипроПРО CSP.

Воспользуйтесь примером перечисления контейнеров КриптоПро в Рутокен SDK: <sdk>\CryptoAPI\CryptoProCSP\Read-GOST34.10-2012-256

Спасибо, что помогаете.
1) Мы не генерируем ключи, нам их сгенерировал оператор для сервиса отчетности с ФНС,Росстат, ПФР и ФСС.
2) На https://ra.rutoken.ru/? сертификат отображается.
Значит, у нас контейнеры не в Формате КриптоПро CSP, а пример, который Вы дали не подойдет? А что подойдет?

Re: Как работать с информацией о сертификате, C_EX_GetCertificateInfoText?

MarErm,

Попробуйте этот шаблон поиска сертификата. В текущем у вас жестко задан идентификатор CKA_ID из примера:

//Шаблон для поиска сертификата                                          

CK_ATTRIBUTE certificateTemplate[] =
{
    { CKA_CLASS, &certificateObject, sizeof(certificateObject)},                      // Класс - сертификат
    { CKA_TOKEN, &attributeTrue, sizeof(attributeTrue)},                              // Сертификат является объектом токена
    { CKA_PRIVATE, &attributeFalse, sizeof(attributeFalse)},                          // Сертификат доступен без аутентификации
    { CKA_CERTIFICATE_TYPE, &certificateType, sizeof(certificateType)},               // Тип сертификата - X.509
    { CKA_CERTIFICATE_CATEGORY, &tokenUserCertificate, sizeof(tokenUserCertificate)}, // Категория сертификата - пользовательский
};

Re: Как работать с информацией о сертификате, C_EX_GetCertificateInfoText?

Помогите, пожалуйста, я совсем запутался. Скачал Microsoft Visual C++ 2019, версия 16.3.6, скачал и установил все пакеты для C++. Открываю папку: sdk-180919-80c054 (1)\sdk\pkcs11\samples\PKIExtensions\GetCertificateInfo-GOST34.10-2012-256, открываю пример двойным кликом и он открывается в IDE. Запускаю. Вчера если он мне почему-то создавал CSR вместо того чтобы читать информацию с токена. У меня не работали точки останова и когда я менял текст в printf, в консоли ничего не менялосб. Я начал искать в интернете, там советуют сделать rebuild solution. Но я сделал, а оно вообще перестало запускаться. Скачал Rutoken SDK заново, открываю только что скаченное, но оно тоже не работает.

При отладке пишет:

'CreateCSR-PKCS10-GOST34.10-2001.exe' (Win32): Loaded 'D:\sdk-180919-80c054\sdk\pkcs11\samples\out\windows-x86-debug\CreateCSR-PKCS10-GOST34.10-2001.exe'. Symbols loaded.
'CreateCSR-PKCS10-GOST34.10-2001.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ntdll.dll'. Symbols loaded.
'CreateCSR-PKCS10-GOST34.10-2001.exe' (Win32): Loaded 'C:\Windows\SysWOW64\kernel32.dll'. Symbols loaded.
'CreateCSR-PKCS10-GOST34.10-2001.exe' (Win32): Loaded 'C:\Windows\SysWOW64\KernelBase.dll'. Symbols loaded.
The thread 0x2958 has exited with code 0 (0x0).
'CreateCSR-PKCS10-GOST34.10-2001.exe' (Win32): Loaded 'C:\Windows\SysWOW64\api-ms-win-core-synch-l1-2-0.dll'. Symbols loaded.
'CreateCSR-PKCS10-GOST34.10-2001.exe' (Win32): Loaded 'D:\sdk-180919-80c054\sdk\pkcs11\samples\out\windows-x86-debug\rtpkcs11ecp.dll'. Module was built without symbols.
'CreateCSR-PKCS10-GOST34.10-2001.exe' (Win32): Loaded 'C:\Windows\SysWOW64\WinSCard.dll'. Symbols loaded.
'CreateCSR-PKCS10-GOST34.10-2001.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msvcrt.dll'. Symbols loaded.
'CreateCSR-PKCS10-GOST34.10-2001.exe' (Win32): Loaded 'C:\Windows\SysWOW64\rpcrt4.dll'. Symbols loaded.
'CreateCSR-PKCS10-GOST34.10-2001.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sspicli.dll'. Symbols loaded.
'CreateCSR-PKCS10-GOST34.10-2001.exe' (Win32): Loaded 'C:\Windows\SysWOW64\cryptbase.dll'. Symbols loaded.
'CreateCSR-PKCS10-GOST34.10-2001.exe' (Win32): Loaded 'C:\Windows\SysWOW64\sechost.dll'. Symbols loaded.
'CreateCSR-PKCS10-GOST34.10-2001.exe' (Win32): Loaded 'C:\Windows\SysWOW64\crypt32.dll'. Symbols loaded.
'CreateCSR-PKCS10-GOST34.10-2001.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msasn1.dll'. Symbols loaded.
'CreateCSR-PKCS10-GOST34.10-2001.exe' (Win32): Loaded 'C:\Windows\SysWOW64\user32.dll'. Symbols loaded.
'CreateCSR-PKCS10-GOST34.10-2001.exe' (Win32): Loaded 'C:\Windows\SysWOW64\gdi32.dll'. Symbols loaded.
'CreateCSR-PKCS10-GOST34.10-2001.exe' (Win32): Loaded 'C:\Windows\SysWOW64\lpk.dll'. Symbols loaded.
'CreateCSR-PKCS10-GOST34.10-2001.exe' (Win32): Loaded 'C:\Windows\SysWOW64\usp10.dll'. Symbols loaded.
'CreateCSR-PKCS10-GOST34.10-2001.exe' (Win32): Loaded 'C:\Windows\SysWOW64\advapi32.dll'. Symbols loaded.
'CreateCSR-PKCS10-GOST34.10-2001.exe' (Win32): Loaded 'C:\Windows\SysWOW64\ole32.dll'. Symbols loaded.
'CreateCSR-PKCS10-GOST34.10-2001.exe' (Win32): Loaded 'C:\Windows\SysWOW64\shell32.dll'. Symbols loaded.
'CreateCSR-PKCS10-GOST34.10-2001.exe' (Win32): Loaded 'C:\Windows\SysWOW64\shlwapi.dll'. Symbols loaded.
'CreateCSR-PKCS10-GOST34.10-2001.exe' (Win32): Loaded 'C:\Program Files (x86)\Common Files\Crypto Pro\AppCompat\cpcrypt.dll'. 
'CreateCSR-PKCS10-GOST34.10-2001.exe' (Win32): Loaded 'C:\Program Files (x86)\Common Files\Crypto Pro\AppCompat\detoured.dll'. 
'CreateCSR-PKCS10-GOST34.10-2001.exe' (Win32): Loaded 'C:\Windows\SysWOW64\psapi.dll'. Symbols loaded.
'CreateCSR-PKCS10-GOST34.10-2001.exe' (Win32): Loaded 'C:\Windows\SysWOW64\imm32.dll'. Symbols loaded.
'CreateCSR-PKCS10-GOST34.10-2001.exe' (Win32): Loaded 'C:\Windows\SysWOW64\msctf.dll'. Symbols loaded.
'CreateCSR-PKCS10-GOST34.10-2001.exe' (Win32): Loaded 'C:\Windows\SysWOW64\winsta.dll'. Symbols loaded.
'CreateCSR-PKCS10-GOST34.10-2001.exe' (Win32): Loaded 'C:\Windows\SysWOW64\wtsapi32.dll'. Symbols loaded.
Exception thrown at 0x7595C54F (KernelBase.dll) in CreateCSR-PKCS10-GOST34.10-2001.exe: 0x000006BA: The RPC server is unavailable.
Exception thrown at 0x7595C54F in CreateCSR-PKCS10-GOST34.10-2001.exe: Microsoft C++ exception: unsigned long at memory location 0x0035FA00.
Exception thrown at 0x7595C54F in CreateCSR-PKCS10-GOST34.10-2001.exe: Microsoft C++ exception: unsigned long at memory location 0x0035FA00.
Exception thrown at 0x7595C54F in CreateCSR-PKCS10-GOST34.10-2001.exe: Microsoft C++ exception: unsigned long at memory location 0x0035FA00.
Exception thrown at 0x7595C54F in CreateCSR-PKCS10-GOST34.10-2001.exe: Microsoft C++ exception: unsigned long at memory location 0x0035FA00.
Exception thrown at 0x7595C54F in CreateCSR-PKCS10-GOST34.10-2001.exe: Microsoft C++ exception: unsigned long at memory location 0x0035FA00.
Exception thrown at 0x7595C54F in CreateCSR-PKCS10-GOST34.10-2001.exe: Microsoft C++ exception: unsigned long at memory location 0x0035FA00.
Exception thrown at 0x7595C54F in CreateCSR-PKCS10-GOST34.10-2001.exe: Microsoft C++ exception: unsigned long at memory location 0x0035FA00.
Exception thrown at 0x7595C54F in CreateCSR-PKCS10-GOST34.10-2001.exe: Microsoft C++ exception: unsigned long at memory location 0x0035FA00.
Exception thrown at 0x7595C54F in CreateCSR-PKCS10-GOST34.10-2001.exe: Microsoft C++ exception: unsigned long at memory location 0x0035FA00.
Exception thrown at 0x7595C54F in CreateCSR-PKCS10-GOST34.10-2001.exe: Microsoft C++ exception: unsigned long at memory location 0x0035FA00.
Exception thrown at 0x7595C54F in CreateCSR-PKCS10-GOST34.10-2001.exe: Microsoft C++ exception: unsigned long at memory location 0x0035FA00.
Exception thrown at 0x7595C54F in CreateCSR-PKCS10-GOST34.10-2001.exe: Microsoft C++ exception: unsigned long at memory location 0x0035FA00.
Exception thrown at 0x7595C54F in CreateCSR-PKCS10-GOST34.10-2001.exe: Microsoft C++ exception: unsigned long at memory location 0x0035FA00.
Exception thrown at 0x7595C54F in CreateCSR-PKCS10-GOST34.10-2001.exe: Microsoft C++ exception: unsigned long at memory location 0x0035FA00.
Exception thrown at 0x7595C54F in CreateCSR-PKCS10-GOST34.10-2001.exe: Microsoft C++ exception: LoadingObjectFailedException at memory location 0x0035F8B4.
Exception thrown at 0x7595C54F in CreateCSR-PKCS10-GOST34.10-2001.exe: Microsoft C++ exception: LoadingObjectFailedException at memory location 0x0035F870.
Exception thrown at 0x7595C54F (KernelBase.dll) in CreateCSR-PKCS10-GOST34.10-2001.exe: 0x0000071A: The remote procedure call was canceled, or if a call time-out was specified, the call timed out.
'CreateCSR-PKCS10-GOST34.10-2001.exe' (Win32): Unloaded 'D:\sdk-180919-80c054\sdk\pkcs11\samples\out\windows-x86-debug\rtpkcs11ecp.dll'
'CreateCSR-PKCS10-GOST34.10-2001.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\shell32.dll'
'CreateCSR-PKCS10-GOST34.10-2001.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\shlwapi.dll'
'CreateCSR-PKCS10-GOST34.10-2001.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\ole32.dll'
'CreateCSR-PKCS10-GOST34.10-2001.exe' (Win32): Unloaded 'C:\Windows\SysWOW64\WinSCard.dll'
The thread 0x1778 has exited with code 0 (0x0).
The thread 0x3570 has exited with code 0 (0x0).
The program '[12760] CreateCSR-PKCS10-GOST34.10-2001.exe' has exited with code 0 (0x0).

При rebuild пишет:

Severity    Code    Description    Project    File    Line    Suppression State    Suppression State
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    SignPKCS7-GOST34.10-2012-512    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    785        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    SignPKCS7-GOST34.10-2001    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    785        
Warning    C4996    'strncat': This function or variable may be unsafe. Consider using strncat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    SignPKCS7-GOST34.10-2001    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    787        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    SignPKCS7-GOST34.10-2001    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    788        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    SignPKCS7-GOST34.10-2001    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    790        
Warning    C4996    'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    SignPKCS7-GOST34.10-2001    D:\sdk-180919-80c054\sdk\pkcs11\samples\PKIExtensions\SignPKCS7-GOST34.10-2001\SignPKCS7-GOST34.10-2001.c    198        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    GetCertificateInfo-GOST34.10-2001    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    785        
Warning    C4996    'strncat': This function or variable may be unsafe. Consider using strncat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    GetCertificateInfo-GOST34.10-2001    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    787        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    GetCertificateInfo-GOST34.10-2001    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    788        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    GetCertificateInfo-GOST34.10-2001    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    790        
Error    MSB3073    The command "copy /Y .\..\..\..\lib\windows-x86\rtpkcs11ecp.dll .\..\..\out\windows-x86-debug\rtpkcs11ecp.dll
:VCEnd" exited with code 1.    SignPKCS7-GOST34.10-2001    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets    148        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    SignPKCS7-GOST34.10-2012-256    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    785        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    DeleteObjects-GOST34.10-2001    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    785        
Warning    C4996    'strncat': This function or variable may be unsafe. Consider using strncat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    DeleteObjects-GOST34.10-2001    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    787        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    DeleteObjects-GOST34.10-2001    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    788        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    DeleteObjects-GOST34.10-2001    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    790        
Warning    C4996    'strncat': This function or variable may be unsafe. Consider using strncat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    SignPKCS7-GOST34.10-2012-256    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    787        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    SignPKCS7-GOST34.10-2012-256    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    788        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    SignPKCS7-GOST34.10-2012-256    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    790        
Warning    C4996    'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    SignPKCS7-GOST34.10-2012-256    D:\sdk-180919-80c054\sdk\pkcs11\samples\PKIExtensions\SignPKCS7-GOST34.10-2012-256\SignPKCS7-GOST34.10-2012-256.c    201        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    GetCertificateInfo-GOST34.10-2012-256    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    785        
Warning    C4996    'strncat': This function or variable may be unsafe. Consider using strncat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    GetCertificateInfo-GOST34.10-2012-256    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    787        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    GetCertificateInfo-GOST34.10-2012-256    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    788        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    GetCertificateInfo-GOST34.10-2012-256    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    790        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    DeleteObjects-GOST34.10-2012-256    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    785        
Warning    C4996    'strncat': This function or variable may be unsafe. Consider using strncat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    DeleteObjects-GOST34.10-2012-256    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    787        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    DeleteObjects-GOST34.10-2012-256    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    788        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    DeleteObjects-GOST34.10-2012-256    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    790        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    VerifyPKCS7    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    785        
Warning    C4996    'strncat': This function or variable may be unsafe. Consider using strncat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    VerifyPKCS7    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    787        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    VerifyPKCS7    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    788        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    VerifyPKCS7    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    790        
Warning    C4996    'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    VerifyPKCS7    D:\sdk-180919-80c054\sdk\pkcs11\samples\PKIExtensions\VerifyPKCS7\VerifyPKCS7.c    154        
Warning    C4996    'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    VerifyPKCS7    D:\sdk-180919-80c054\sdk\pkcs11\samples\PKIExtensions\VerifyPKCS7\VerifyPKCS7.c    187        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    SignPKCS7Detached-GOST34.10-2001    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    785        
Warning    C4996    'strncat': This function or variable may be unsafe. Consider using strncat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    SignPKCS7Detached-GOST34.10-2001    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    787        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    SignPKCS7Detached-GOST34.10-2001    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    788        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    SignPKCS7Detached-GOST34.10-2001    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    790        
Warning    C4996    'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    SignPKCS7Detached-GOST34.10-2001    D:\sdk-180919-80c054\sdk\pkcs11\samples\PKIExtensions\SignPKCS7Detached-GOST34.10-2001\SignPKCS7Detached-GOST34.10-2001.c    199        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    VerifyPKCS7Detached    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    785        
Warning    C4996    'strncat': This function or variable may be unsafe. Consider using strncat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    VerifyPKCS7Detached    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    787        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    VerifyPKCS7Detached    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    788        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    VerifyPKCS7Detached    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    790        
Warning    C4996    'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    VerifyPKCS7Detached    D:\sdk-180919-80c054\sdk\pkcs11\samples\PKIExtensions\VerifyPKCS7Detached\VerifyPKCS7Detached.c    161        
Warning    C4996    'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    VerifyPKCS7Detached    D:\sdk-180919-80c054\sdk\pkcs11\samples\PKIExtensions\VerifyPKCS7Detached\VerifyPKCS7Detached.c    194        
Error    MSB3073    The command "copy /Y .\..\..\..\lib\windows-x86\rtpkcs11ecp.dll .\..\..\out\windows-x86-debug\rtpkcs11ecp.dll
:VCEnd" exited with code 1.    SignPKCS7Detached-GOST34.10-2001    C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\MSBuild\Microsoft\VC\v160\Microsoft.CppCommon.targets    148        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    DeleteObjects-GOST34.10-2012-512    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    785        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    GetCertificateInfo-GOST34.10-2012-512    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    785        
Warning    C4996    'strncat': This function or variable may be unsafe. Consider using strncat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    GetCertificateInfo-GOST34.10-2012-512    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    787        
Warning    C4996    'strncat': This function or variable may be unsafe. Consider using strncat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    DeleteObjects-GOST34.10-2012-512    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    787        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    GetCertificateInfo-GOST34.10-2012-512    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    788        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    GetCertificateInfo-GOST34.10-2012-512    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    790        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    DeleteObjects-GOST34.10-2012-512    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    788        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    DeleteObjects-GOST34.10-2012-512    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    790        
Warning    C4996    'strncat': This function or variable may be unsafe. Consider using strncat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    SignPKCS7-GOST34.10-2012-512    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    787        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    SignPKCS7-GOST34.10-2012-512    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    788        
Warning    C4996    'strcat': This function or variable may be unsafe. Consider using strcat_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    SignPKCS7-GOST34.10-2012-512    D:\sdk-180919-80c054\sdk\pkcs11\samples\include\Common.h    790        
Warning    C4996    'fopen': This function or variable may be unsafe. Consider using fopen_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.    SignPKCS7-GOST34.10-2012-512    D:\sdk-180919-80c054\sdk\pkcs11\samples\PKIExtensions\SignPKCS7-GOST34.10-2012-512\SignPKCS7-GOST34.10-2012-512.c    200        

Re: Как работать с информацией о сертификате, C_EX_GetCertificateInfoText?

Может я вообще не ту IDE использую? Не той версии? Может нужно сделать какие-то настройки в проекте, что-то прописать, какие-то пути?

Re: Как работать с информацией о сертификате, C_EX_GetCertificateInfoText?

Окей я что-то делал по инструкциям из интернета и оно запустилось

Re: Как работать с информацией о сертификате, C_EX_GetCertificateInfoText?

Я запускаю пример с получением информации, но программа почему-то начинает... создавать сертификат? Она пишет "Creating has been completed successfully."

Initialization hi!!...
 LoadLibrary -> OK
 GetProcAddress (C_GetFunctionList) -> OK
 GetProcAddress (C_EX_GetFunctionListExtended) -> OK
 Get function list -> OK
 Get function list extended -> OK
 C_Initialize -> OK
 C_GetSlotList (number of slots) -> OK
 Checking available tokens -> OK
 Memory allocation for slots -> OK
 C_GetSlotList -> OK
 Slots available: 1
 C_GetMechanismList (number of mechanisms) -> OK
 Checking mechanisms available -> OK
 Memory allocation for mechanisms -> OK
 C_GetMechanismList -> OK
 Checking CKM_GOSTR3410_KEY_PAIR_GEN support -> OK
 C_OpenSession -> OK
 C_Login -> OK
Initialization has been completed successfully.

Creating CSR...
 C_GenerateKeyPair -> OK
 C_EX_CreateCSR -> OK
 Get CSR in Base64 format -> OK

Certificate request is:
-----BEGIN NEW CERTIFICATE REQUEST-----
MIICMzCCAeACAQAwgacxFTATBgNVBAM**********************************
UlUxFD*************************zEyMR0wGwYJKoZIhvcNAQkBDA5pdmFub3ZA
bWFpbC5ydTEVMBMG******************************gYDVQQKDAtDb21wYW55
*************************GV2ZWwxDzANBgNVBAcMBk1vc2NvdzBjMBwGBiqFAwIC
EzASBgcqhQMCAiMBBgcqhQMCAh4BA0MABEDwstGq1YZtfcXdtpIrYBNmmOHC23fA
/kLuYveLCGooIXf0sKyMLg38*********************************************
...............888888888888889gbcwCwYDVR0PBAQDAgTwMCYGA1UdJQQfMB0GByqFAwIC
IgYGCCsGAQUFBwMCBggrBgEFBQcDBDAdBgNVHQ4EFgQU/hF7k87GtQZeFhPhVdOp
yll8D4EwGAYDVR0RBBEwD4ENZXhhbXBsZUB5YS5ydTAWBgNVHSABAf8EDDAKMAgG
BiqFA2RxATAvBgUqh9**********************************************
ptCfIDIuMCIwCgYGKoUDAgIDBQADQQDzEI7xG7xwSXMVPq4FHWQLrZ2EXVAX9nRs
NzlSK***********************RhL3qYlDE8luCD8tL2m0KrfkNK
-----END NEW CERTIFICATE REQUEST-----

Creating has been completed successfully.

Finalizing...
 C_EX_FreeBuffer -> OK
 C_Logout -> OK
 C_CloseSession -> OK
 C_Finalize -> OK
 FreeLibrary -> OK


Sample has been completed successfully.

D:\sdk-180919-80c054\sdk\pkcs11\samples\PKIExtensions\CreateCSR-PKCS10-GOST34.10
-2001\.\..\..\out\windows-x86-debug\CreateCSR-PKCS10-GOST34.10-2001.exe (process
 5548) exited with code 0.
To automatically close the console when debugging stops, enable Tools->Options->
Debugging->Automatically close the console when debugging stops.
Press any key to close this window . . .

Re: Как работать с информацией о сертификате, C_EX_GetCertificateInfoText?

Как мне запустить именно пример с получением сертификата? Точки останова все еще не работают, не могу понять что происходит. Как будто программа в какой-то момент перескакивает в соседний пример

Re: Как работать с информацией о сертификате, C_EX_GetCertificateInfoText?

MarErm, все логично, вы запускаете пример создания запроса на сертификат. Он по умолчанию выбран проектом для запуска.

Sample has been completed successfully.

D:\sdk-180919-80c054\sdk\pkcs11\samples\PKIExtensions\CreateCSR-PKCS10-GOST34.10
-2001\.\..\..\out\windows-x86-debug\CreateCSR-PKCS10-GOST34.10-2001.exe (process
5548) exited with code 0.

В Visual Studio кликните правой кнопкой мыши на GetCertificateInfo-GOST34.10-XXXXXX и выберите пункт "Set as StartUp Project", затем нажмите F5

Re: Как работать с информацией о сертификате, C_EX_GetCertificateInfoText?

С новым шаблоном. Не может проверить количество сертификатов.

Initialization hi...
 LoadLibrary -> OK
 GetProcAddress (C_GetFunctionList) -> OK
 GetProcAddress (C_EX_GetFunctionListExtended) -> OK
 Get function list -> OK
 Get function list extended -> OK
 C_Initialize -> OK
 C_GetSlotList (number of slots) -> OK
 Checking available tokens -> OK
 Memory allocation for slots -> OK
 C_GetSlotList -> OK
 Slots available: 1
 C_OpenSession -> OK
 C_Login -> OK
Initialization has been completed successfully.

Getting information...
 Getting certificates...
  C_FindObjectsInit -> OK
  Memory allocation for object handles -> OK
  C_FindObjects -> OK
  C_FindObjectsFinal -> OK
 findObjects -> OK
 Checking number of certificates -> Failed
No objects found

 C_Logout -> OK
 C_CloseSession -> OK
 C_Finalize -> OK
 FreeLibrary -> OK


Some error occurred. Sample failed.

D:\sdk-180919-80c054\sdk\pkcs11\samples\PKIExtensions\GetCertificateInfo-GOST34.
10-2012-256\.\..\..\out\windows-x86-debug\GetCertificateInfo-GOST34.10-2012-256.
exe (process 14632) exited with code 1.
To automatically close the console when debugging stops, enable Tools->Options->
Debugging->Automatically close the console when debugging stops.
Press any key to close this window . . .

Re: Как работать с информацией о сертификате, C_EX_GetCertificateInfoText?

MarErm, у вас в отладчике objectCount == 0?

Покажите, пожалуйста, скриншот с ra.rutoken.ru.

Re: Как работать с информацией о сертификате, C_EX_GetCertificateInfoText?

Скриншот с https://ra.rutoken.ru/devices/list
http://forum.rutoken.ru/uploads/images/2019/11/b0596f24a0c236ee44e79fd2f11864a0.png

(2019-11-12 11:40:23 отредактировано MarErm)

Re: Как работать с информацией о сертификате, C_EX_GetCertificateInfoText?

отладчик
http://forum.rutoken.ru/uploads/images/2019/11/b10b74867b730a441622c0ccb6016a31.png

ближе:
http://forum.rutoken.ru/uploads/images/2019/11/fdd408e908fd22b7edb7f328603d59e3.png

Re: Как работать с информацией о сертификате, C_EX_GetCertificateInfoText?

MarErm, у вас довольно странный скриншот с ra.rutoken.ru.

Он после чтения Рутокена отображает содержимое? Должно отобразиться примерно вот такое:http://forum.rutoken.ru/uploads/images/2019/11/0b095e232bc5babd10959dda067bf03d.png


Пример не отрабатывает поскольку не находит на токене сертификат.

Re: Как работать с информацией о сертификате, C_EX_GetCertificateInfoText?

Скриншот с другого компьютера. Не могу найти где посмотреть контейнер
http://forum.rutoken.ru/uploads/images/2019/11/2f62859f03623b24c75eb48f80bf3131.png