SUPPORT-8592. Переименована настройка sign::pin в sign::sign_cert_password
This commit is contained in:
parent
4c1e5c3562
commit
59005fe670
7 changed files with 30 additions and 32 deletions
|
|
@ -91,7 +91,7 @@ fcgi_thread_pool_size = 1 *\# значение по умолчанию: 1*
|
||||||
- В секции **\[sign\]** задать настройки модуля подписания:
|
- В секции **\[sign\]** задать настройки модуля подписания:
|
||||||
location = /sign *\# значение по умолчанию: /sign, должно совпадать со значением в nginx.conf*
|
location = /sign *\# значение по умолчанию: /sign, должно совпадать со значением в nginx.conf*
|
||||||
signer_subject = signer@example.ru *\# email, ИНН, СНИЛС или любая другая строка из свойства контейнера «Субъект»*
|
signer_subject = signer@example.ru *\# email, ИНН, СНИЛС или любая другая строка из свойства контейнера «Субъект»*
|
||||||
pin = \*\*\*\* *\# пароль от контейнера*
|
sign_cert_password = \*\*\*\* *\# пароль от контейнера*
|
||||||
|
|
||||||
- В секции **\[verify\]** задать настройки проверки подписи маркера доступа:
|
- В секции **\[verify\]** задать настройки проверки подписи маркера доступа:
|
||||||
location = /verify *\# значение по умолчанию: /verify, должно совпадать со значением в nginx.conf*
|
location = /verify *\# значение по умолчанию: /verify, должно совпадать со значением в nginx.conf*
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@ fcgi_listen_host = 127.0.0.1
|
||||||
[sign]
|
[sign]
|
||||||
#location = /sign
|
#location = /sign
|
||||||
signer_subject = signer@example.ru
|
signer_subject = signer@example.ru
|
||||||
pin = ****
|
sign_cert_password = ****
|
||||||
|
|
||||||
[verify]
|
[verify]
|
||||||
#location = /verify
|
#location = /verify
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@
|
||||||
#define SIGN_CONF_SECTION "sign"
|
#define SIGN_CONF_SECTION "sign"
|
||||||
#define SIGN_CONF_KEY_LOCATION "location"
|
#define SIGN_CONF_KEY_LOCATION "location"
|
||||||
#define SIGN_CONF_KEY_SIGNER "signer_subject"
|
#define SIGN_CONF_KEY_SIGNER "signer_subject"
|
||||||
#define SIGN_CONF_KEY_PIN "pin"
|
#define SIGN_CONF_KEY_PASSWORD "sign_cert_password"
|
||||||
|
|
||||||
#define FCGI_OK_RESPONSE_FORMAT \
|
#define FCGI_OK_RESPONSE_FORMAT \
|
||||||
"Content-type: text/plain" CRLF\
|
"Content-type: text/plain" CRLF\
|
||||||
|
|
@ -66,8 +66,8 @@ sign_conf_load(sign_conf_t *conf, const conf_file_context_t conf_file)
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
SIGN_CONF_SECTION,
|
SIGN_CONF_SECTION,
|
||||||
SIGN_CONF_KEY_PIN,
|
SIGN_CONF_KEY_PASSWORD,
|
||||||
&(conf->pin),
|
&(conf->sign_cert_password),
|
||||||
CONF_FILE_VALUE_STRT,
|
CONF_FILE_VALUE_STRT,
|
||||||
CONF_FILE_VALUE_PSWD,
|
CONF_FILE_VALUE_PSWD,
|
||||||
NULL
|
NULL
|
||||||
|
|
@ -94,10 +94,10 @@ sign_conf_clear(sign_conf_t *conf)
|
||||||
|
|
||||||
if (conf == NULL) return;
|
if (conf == NULL) return;
|
||||||
|
|
||||||
if (conf->pin.data != 0) {
|
if (conf->sign_cert_password.data != 0) {
|
||||||
explicit_bzero(conf->pin.data, conf->pin.len);
|
explicit_bzero(conf->sign_cert_password.data, conf->sign_cert_password.len);
|
||||||
}
|
}
|
||||||
str_t_clear(&conf->pin);
|
str_t_clear(&conf->sign_cert_password);
|
||||||
|
|
||||||
str_t_clear(&conf->location);
|
str_t_clear(&conf->location);
|
||||||
free(conf->signer);
|
free(conf->signer);
|
||||||
|
|
@ -118,7 +118,7 @@ sign_service_create(const sign_conf_t *conf)
|
||||||
|
|
||||||
hsign->conf = conf;
|
hsign->conf = conf;
|
||||||
|
|
||||||
cryptopro_context_set(&hsign->cryptopro_ctx, conf->signer, &conf->pin);
|
cryptopro_context_set(&hsign->cryptopro_ctx, conf->signer, &conf->sign_cert_password);
|
||||||
|
|
||||||
LOG_TRACE("sign_service_create exit");
|
LOG_TRACE("sign_service_create exit");
|
||||||
return (HSign)hsign;
|
return (HSign)hsign;
|
||||||
|
|
|
||||||
|
|
@ -12,7 +12,7 @@ typedef struct sign_conf_s {
|
||||||
str_t location;
|
str_t location;
|
||||||
|
|
||||||
char *signer; /* субъект контейнера */
|
char *signer; /* субъект контейнера */
|
||||||
str_t pin; /* pin-код от контейнера */
|
str_t sign_cert_password; /* пароль от контейнера */
|
||||||
|
|
||||||
} sign_conf_t;
|
} sign_conf_t;
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ static HCERTSTORE cert_open_store();
|
||||||
|
|
||||||
static PCCERT_CONTEXT get_signer_cert(const cryptopro_context_t *ctx, HCERTSTORE hStoreHandle);
|
static PCCERT_CONTEXT get_signer_cert(const cryptopro_context_t *ctx, HCERTSTORE hStoreHandle);
|
||||||
|
|
||||||
static int set_pin(PCCERT_CONTEXT pSignerCert, const str_t *pin);
|
static int set_password(PCCERT_CONTEXT cert_ctx, const str_t *password);
|
||||||
|
|
||||||
bool
|
bool
|
||||||
cryptopro_init(const char* cp_file)
|
cryptopro_init(const char* cp_file)
|
||||||
|
|
@ -45,7 +45,7 @@ cryptopro_sign(const cryptopro_context_t *ctx, const str_t *data, /*out*/ str_t
|
||||||
|
|
||||||
assert(ctx != NULL);
|
assert(ctx != NULL);
|
||||||
assert(ctx->signer != NULL);
|
assert(ctx->signer != NULL);
|
||||||
assert(ctx->pin != NULL);
|
assert(ctx->password != NULL);
|
||||||
assert(data != NULL && !str_t_is_null(*data));
|
assert(data != NULL && !str_t_is_null(*data));
|
||||||
assert(sign != NULL);
|
assert(sign != NULL);
|
||||||
|
|
||||||
|
|
@ -211,45 +211,43 @@ cert_open_store()
|
||||||
static PCCERT_CONTEXT
|
static PCCERT_CONTEXT
|
||||||
get_signer_cert(const cryptopro_context_t *ctx, HCERTSTORE hStoreHandle)
|
get_signer_cert(const cryptopro_context_t *ctx, HCERTSTORE hStoreHandle)
|
||||||
{
|
{
|
||||||
PCCERT_CONTEXT pSignerCert;
|
PCCERT_CONTEXT cert_ctx = cp_function_list.CertFindCertificateInStore(hStoreHandle,
|
||||||
|
|
||||||
pSignerCert = cp_function_list.CertFindCertificateInStore(hStoreHandle,
|
|
||||||
X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
|
X509_ASN_ENCODING | PKCS_7_ASN_ENCODING,
|
||||||
0,
|
0,
|
||||||
CERT_FIND_SUBJECT_STR,
|
CERT_FIND_SUBJECT_STR,
|
||||||
ctx->signer,
|
ctx->signer,
|
||||||
NULL);
|
NULL);
|
||||||
if (pSignerCert == NULL) {
|
if (cert_ctx == NULL) {
|
||||||
LOG_ERROR("Could not find certificate in store");
|
LOG_ERROR("Could not find certificate in store");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (set_pin(pSignerCert, ctx->pin)) {
|
if (set_password(cert_ctx, ctx->password)) {
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
LOG_DEBUG("The signer's certificate was found");
|
LOG_DEBUG("The signer's certificate was found");
|
||||||
return pSignerCert;
|
return cert_ctx;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
if (pSignerCert) {
|
if (cert_ctx) {
|
||||||
cp_function_list.CertFreeCertificateContext(pSignerCert);
|
cp_function_list.CertFreeCertificateContext(cert_ctx);
|
||||||
}
|
}
|
||||||
LOG_ERROR("get_signer_cert exit with error");
|
LOG_ERROR("get_signer_cert exit with error");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
set_pin(PCCERT_CONTEXT pSignerCert, const str_t *pin)
|
set_password(PCCERT_CONTEXT cert_ctx, const str_t *password)
|
||||||
{
|
{
|
||||||
DWORD dwSize;
|
DWORD dwSize;
|
||||||
if (!cp_function_list.CertGetCertificateContextProperty(
|
if (!cp_function_list.CertGetCertificateContextProperty(
|
||||||
pSignerCert,
|
cert_ctx,
|
||||||
CERT_KEY_PROV_INFO_PROP_ID,
|
CERT_KEY_PROV_INFO_PROP_ID,
|
||||||
NULL,
|
NULL,
|
||||||
&dwSize)) {
|
&dwSize)) {
|
||||||
LOG_ERROR("Error getting key property");
|
LOG_ERROR("Error getting key property");
|
||||||
LOG_ERROR("set_pin exit with error. Last error code: 0x%08x", cp_function_list.GetLastError());
|
LOG_ERROR("set_password exit with error. Last error code: 0x%08x", cp_function_list.GetLastError());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -257,7 +255,7 @@ set_pin(PCCERT_CONTEXT pSignerCert, const str_t *pin)
|
||||||
CRYPT_KEY_PROV_INFO* pKeyInfo = (CRYPT_KEY_PROV_INFO*) pKeyInfoBuffer;
|
CRYPT_KEY_PROV_INFO* pKeyInfo = (CRYPT_KEY_PROV_INFO*) pKeyInfoBuffer;
|
||||||
|
|
||||||
if (!cp_function_list.CertGetCertificateContextProperty(
|
if (!cp_function_list.CertGetCertificateContextProperty(
|
||||||
pSignerCert,
|
cert_ctx,
|
||||||
CERT_KEY_PROV_INFO_PROP_ID,
|
CERT_KEY_PROV_INFO_PROP_ID,
|
||||||
pKeyInfo,
|
pKeyInfo,
|
||||||
&dwSize)){
|
&dwSize)){
|
||||||
|
|
@ -272,14 +270,14 @@ set_pin(PCCERT_CONTEXT pSignerCert, const str_t *pin)
|
||||||
memset(&keyProvParam, 0, sizeof(CRYPT_KEY_PROV_PARAM));
|
memset(&keyProvParam, 0, sizeof(CRYPT_KEY_PROV_PARAM));
|
||||||
keyProvParam.dwFlags = 0;
|
keyProvParam.dwFlags = 0;
|
||||||
keyProvParam.dwParam = keyType;
|
keyProvParam.dwParam = keyType;
|
||||||
keyProvParam.cbData = (DWORD)(pin->len + 1);
|
keyProvParam.cbData = (DWORD)(password->len + 1);
|
||||||
keyProvParam.pbData = (BYTE*) pin->data;
|
keyProvParam.pbData = (BYTE*) password->data;
|
||||||
|
|
||||||
pKeyInfo->cProvParam = 1;
|
pKeyInfo->cProvParam = 1;
|
||||||
pKeyInfo->rgProvParam = &keyProvParam;
|
pKeyInfo->rgProvParam = &keyProvParam;
|
||||||
|
|
||||||
if (!cp_function_list.CertSetCertificateContextProperty(
|
if (!cp_function_list.CertSetCertificateContextProperty(
|
||||||
pSignerCert,
|
cert_ctx,
|
||||||
CERT_KEY_PROV_INFO_PROP_ID,
|
CERT_KEY_PROV_INFO_PROP_ID,
|
||||||
0,
|
0,
|
||||||
pKeyInfo)) {
|
pKeyInfo)) {
|
||||||
|
|
@ -290,7 +288,7 @@ set_pin(PCCERT_CONTEXT pSignerCert, const str_t *pin)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
error:
|
error:
|
||||||
LOG_ERROR("set_pin exit with error. Last error code: 0x%08x", cp_function_list.GetLastError());
|
LOG_ERROR("set_password exit with error. Last error code: 0x%08x", cp_function_list.GetLastError());
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,17 +9,17 @@
|
||||||
|
|
||||||
typedef struct cryptopro_context_s {
|
typedef struct cryptopro_context_s {
|
||||||
const char *signer;
|
const char *signer;
|
||||||
const str_t *pin;
|
const str_t *password;
|
||||||
} cryptopro_context_t;
|
} cryptopro_context_t;
|
||||||
|
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
cryptopro_context_set(cryptopro_context_t *ctx, const char *signer, const str_t *pin)
|
cryptopro_context_set(cryptopro_context_t *ctx, const char *signer, const str_t *password)
|
||||||
{
|
{
|
||||||
assert(ctx != NULL);
|
assert(ctx != NULL);
|
||||||
|
|
||||||
ctx->signer = signer;
|
ctx->signer = signer;
|
||||||
ctx->pin = pin;
|
ctx->password = password;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cryptopro_init(const char* cp_file);
|
bool cryptopro_init(const char* cp_file);
|
||||||
|
|
|
||||||
|
|
@ -49,7 +49,7 @@ chown -R ervu:ervu /var/opt/cprocsp/keys/ervu/key_cont.000/
|
||||||
- Поле "Субъект": любая подстрока из этого поля является signer_subject (нужно будет указать в конфигурационном файле модуля подписания)
|
- Поле "Субъект": любая подстрока из этого поля является signer_subject (нужно будет указать в конфигурационном файле модуля подписания)
|
||||||
- Поле "Ссылка на ключ": убедиться, что значение равно "Есть" (иначе необходимо проверить выполнение предыдущих шагов)
|
- Поле "Ссылка на ключ": убедиться, что значение равно "Есть" (иначе необходимо проверить выполнение предыдущих шагов)
|
||||||
|
|
||||||
4. (опционально) Сделать тестовую подпись с помощью установленного контейнера и полученных значений \<signer_subject\> и \<pin\>:
|
4. (опционально) Сделать тестовую подпись с помощью установленного контейнера и полученных значений \<signer_subject\> и \<sign_cert_password\>:
|
||||||
``` bash
|
``` bash
|
||||||
touch test.txt
|
touch test.txt
|
||||||
/opt/cprocsp/bin/amd64/cryptcp -signf -dn <signer_subject> ./test.txt
|
/opt/cprocsp/bin/amd64/cryptcp -signf -dn <signer_subject> ./test.txt
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue