<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Форум Рутокен &mdash; FreeBSD, Рутокен ЭЦП 3.0, OpenSSL запрос на сертификат]]></title>
	<link rel="self" href="https://forum.rutoken.ru/feed/atom/topic/3874/" />
	<updated>2023-03-14T17:29:29Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.rutoken.ru/topic/3874/</id>
		<entry>
			<title type="html"><![CDATA[Re: FreeBSD, Рутокен ЭЦП 3.0, OpenSSL запрос на сертификат]]></title>
			<link rel="alternate" href="https://forum.rutoken.ru/post/19844/#p19844" />
			<content type="html"><![CDATA[<p>К сожалению, так и не смог найти под FreeBSD аналог libengine-pkcs11-openssl, поэтому и надеялся, что rtengine поможет в связке OpenSSL-Rutoken.</p><p>Может быть будет кому-нибудь полезно:<br />оказывается в составе pkcs11-tool есть утилита которая умеет создавать запрос на сертификат. <br />На моем примере:<br />1.&nbsp; Создаем запрос <br /></p><div class="codebox"><pre><code>p11req -l /usr/local/lib/librtpkcs11ecp.so -s 0 -i &#039;test_key&#039; -d &#039;/CN=Test/&#039; -o test_key.csr</code></pre></div><p>2. Подписываем <br /></p><div class="codebox"><pre><code>openssl ca -config ./openssl.cnf -in test_key.csr -out test_key.crt</code></pre></div><p>3. Загружаем в токен<br /></p><div class="codebox"><pre><code>pkcs11-tool --module /usr/local/lib/librtpkcs11ecp.so --type cert -w test_key.crt --id 01 --label test_key</code></pre></div><p>Профит<br /></p><div class="codebox"><pre><code>Public Key Object; RSA 2048 bits
  label:      test_key
  ID:         01
  Usage:      encrypt, verify, wrap
  Access:     local
Private Key Object; RSA 
  label:      test_key
  ID:         01
  Usage:      decrypt, sign, unwrap
  Access:     sensitive, always sensitive, never extractable, local
Public Key Object; RSA 2048 bits
  label:      test2_1
  ID:         c022ba7a6f620778
  Usage:      encrypt, verify, wrap
  Access:     local
Private Key Object; RSA 
  label:      test2_1
  ID:         c022ba7a6f620778
  Usage:      decrypt, sign, unwrap
  Access:     sensitive, always sensitive, never extractable, local
Public Key Object; GOSTR3410-2012-256
  PARAMS OID: 06072a850302022301
  VALUE:      78ee9ed140e7f9e55e4634b7e036986b6b7d5014e5d6fc69795e4fc0950c9085
              839df0f5346da5c5044fe981103b91a1911f8ddd25d13b851b8fee86bc45b8a8
  label:      
  ID:         02
  Usage:      verify
  Access:     local
Private Key Object; GOSTR3410-2012-256
  PARAMS OID: 06072a850302022301
  label:      
  ID:         02
  Usage:      sign
  Access:     sensitive, always sensitive, never extractable, local
Certificate Object; type = X.509 cert
  label:      test2_1
  subject:    DN: CN=test2_1
  serial:     58FDC40185935F36
  ID:         c022ba7a6f620778
Certificate Object; type = X.509 cert
  label:      test_key
  subject:    DN: CN=Test
  serial:     09
  ID:         01</code></pre></div>]]></content>
			<author>
				<name><![CDATA[sciram]]></name>
				<uri>https://forum.rutoken.ru/user/13314/</uri>
			</author>
			<updated>2023-03-14T17:29:29Z</updated>
			<id>https://forum.rutoken.ru/post/19844/#p19844</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: FreeBSD, Рутокен ЭЦП 3.0, OpenSSL запрос на сертификат]]></title>
			<link rel="alternate" href="https://forum.rutoken.ru/post/19838/#p19838" />
			<content type="html"><![CDATA[<p><strong>sciram</strong>, rtengine работает только с ГОСТ ключами. <br />Создать запрос на сертификат через него с RSA ключом не получится.<br />Для работы с RSA необходимо установить пакет libengine-pkcs11-openssl или аналогичный для вашей ОС.<br />Пример создания самоподписанного сертификата на основе RSA ключа есть по ссылке <a href="https://dev.rutoken.ru/pages/viewpage.action?pageId=3440696#id-ЛокальнаяаутентификацияпоРутокенЭЦПвUbuntu/Debian-СозданиесертификатаиимпортегонатокенчерезOpenSSL1.1.x">https://dev.rutoken.ru/pages/viewpage.a … enSSL1.1.x</a></p>]]></content>
			<author>
				<name><![CDATA[Аверченко Кирилл]]></name>
				<uri>https://forum.rutoken.ru/user/11551/</uri>
			</author>
			<updated>2023-03-14T13:34:47Z</updated>
			<id>https://forum.rutoken.ru/post/19838/#p19838</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: FreeBSD, Рутокен ЭЦП 3.0, OpenSSL запрос на сертификат]]></title>
			<link rel="alternate" href="https://forum.rutoken.ru/post/19837/#p19837" />
			<content type="html"><![CDATA[<p>Здравствуйте!<br />dynamic_path раскомментировал, OPENSSL_CONF прописал<br /></p><div class="codebox"><pre><code>openssl engine

(rdrand) Intel RDRAND engine
(dynamic) Dynamic engine loading support
(rtengine) Rutoken engine</code></pre></div><p>запрос на RSA сертификат:<br /></p><div class="codebox"><pre><code>openssl req -utf8 -new -subj &#039;/CN=test/&#039; -sha256 -engine rtengine -keyform engine -key &quot;pkcs11:model=Rutoken%20ECP;manufacturer=Aktiv%20Co.;serial=418958c3;token=Rutoken%20ECP%20%3Cno%20label%3E;id=%01&quot; -passin pass:&quot;12345678&quot;
engine &quot;rtengine&quot; set.
cannot load Private Key from engine
34389172224:error:8107D0E6:lib(129):init_algorithm_nid:unknown key type:engine/p11/gost_key.c:52:
34389172224:error:810A10F0:lib(129):rt_eng_get0_ec_key:wrong key:engine/ec.c:53:
34389172224:error:26096080:engine routines:ENGINE_load_private_key:failed loading private key:/usr/src/crypto/openssl/crypto/engine/eng_pkey.c:78:
unable to load Private Key</code></pre></div><p>После убирания -sha256&nbsp; запрос на ГОСТ сертификат отработал правильно. Спасибо!</p>]]></content>
			<author>
				<name><![CDATA[sciram]]></name>
				<uri>https://forum.rutoken.ru/user/13314/</uri>
			</author>
			<updated>2023-03-14T12:52:49Z</updated>
			<id>https://forum.rutoken.ru/post/19837/#p19837</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: FreeBSD, Рутокен ЭЦП 3.0, OpenSSL запрос на сертификат]]></title>
			<link rel="alternate" href="https://forum.rutoken.ru/post/19831/#p19831" />
			<content type="html"><![CDATA[<p><strong>sciram</strong>, добрый день.<br />1. В конфиге openssl необходимо раскомментировать строку dynamic_path.<br />2. После этого необходимо убедиться, что rtengine загружается командой openssl engine<br />3. В команде создания запроса на ключе ГОСТ необходимо убрать -sha256 (Это значение хеша для RSA ключей)</p>]]></content>
			<author>
				<name><![CDATA[Аверченко Кирилл]]></name>
				<uri>https://forum.rutoken.ru/user/11551/</uri>
			</author>
			<updated>2023-03-14T06:40:55Z</updated>
			<id>https://forum.rutoken.ru/post/19831/#p19831</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[FreeBSD, Рутокен ЭЦП 3.0, OpenSSL запрос на сертификат]]></title>
			<link rel="alternate" href="https://forum.rutoken.ru/post/19826/#p19826" />
			<content type="html"><![CDATA[<p>Здравствуйте!</p><p>FreeBSD 13.1, Рутокен ЭЦП 3.0</p><p>pkcs11-tool токен видит, ключи добавляет/удаляет:<br /></p><div class="codebox"><pre><code>pkcs11-tool --module librtpkcs11ecp.so -Ol --pin &#039;12345678&#039;

Public Key Object; RSA 2048 bits
  label:      test_key
  ID:         01
  Usage:      encrypt, verify, wrap
  Access:     local
Private Key Object; RSA 
  label:      test_key
  ID:         01
  Usage:      decrypt, sign, unwrap
  Access:     sensitive, always sensitive, never extractable, local
Public Key Object; RSA 2048 bits
  label:      test2_1
  ID:         c022ba7a6f620778
  Usage:      encrypt, verify, wrap
  Access:     local
Private Key Object; RSA 
  label:      test2_1
  ID:         c022ba7a6f620778
  Usage:      decrypt, sign, unwrap
  Access:     sensitive, always sensitive, never extractable, local
Public Key Object; GOSTR3410-2012-256
  PARAMS OID: 06072a850302022301
  VALUE:      78ee9ed140e7f9e55e4634b7e036986b6b7d5014e5d6fc69795e4fc0950c9085
              839df0f5346da5c5044fe981103b91a1911f8ddd25d13b851b8fee86bc45b8a8
  label:      
  ID:         02
  Usage:      verify
  Access:     local
Private Key Object; GOSTR3410-2012-256
  PARAMS OID: 06072a850302022301
  label:      
  ID:         02
  Usage:      sign
  Access:     sensitive, always sensitive, never extractable, local
Certificate Object; type = X.509 cert
  label:      test2_1
  subject:    DN: CN=test2_1
  serial:     58FDC40185935F36
  ID:         c022ba7a6f620778</code></pre></div><p> </p><p>Но не получается создать запрос на сертификат с помощью OpenSSL<br />ГОСТ:<br /></p><div class="codebox"><pre><code>openssl req -utf8 -new -config openssl_rutoken.cnf -subj &#039;/CN=test/&#039; -sha256 -engine rtengine -keyform engine -key &quot;pkcs11:model=Rutoken%20ECP;manufacturer=Aktiv%20Co.;serial=418958c3;token=Rutoken%20ECP%20%3Cno%20label%3E;id=%02&quot; -passin pass:&quot;12345678&quot;

engine &quot;rtengine&quot; set.
34389172224:error:8007506F:lib(128):PKEY_GOST_CTRL:invalid digest type:engine/orig/gost_pmeth.c:126:</code></pre></div><p>RSA:<br /></p><div class="codebox"><pre><code>openssl req -utf8 -new -config openssl_rutoken.cnf -subj &#039;/CN=test/&#039; -sha256 -engine rtengine -keyform engine -key &quot;pkcs11:model=Rutoken%20ECP;manufacturer=Aktiv%20Co.;serial=418958c3;token=Rutoken%20ECP%20%3Cno%20label%3E;id=%01&quot; -passin pass:&quot;12345678&quot;

engine &quot;rtengine&quot; set.
cannot load Private Key from engine
34389172224:error:8107D0E6:lib(129):init_algorithm_nid:unknown key type:engine/p11/gost_key.c:52:
34389172224:error:810A10F0:lib(129):rt_eng_get0_ec_key:wrong key:engine/ec.c:53:
34389172224:error:26096080:engine routines:ENGINE_load_private_key:failed loading private key:/usr/src/crypto/openssl/crypto/engine/eng_pkey.c:78:
unable to load Private Key</code></pre></div><p>конфигурационный файл openssl_rutoken.cnf:<br /></p><div class="codebox"><pre><code>openssl_conf = openssl_def
...
[ openssl_def ]
engines = engine_section

[ engine_section ]
rtengine = gost_section

[ gost_section ]
#dynamic_path = /usr/local/lib/librtengine.so.1.5.0
pkcs11_path = /usr/local/lib/librtpkcs11ecp.so
rand_token = pkcs11:model=Rutoken%20ECP;serial=418958c3
default_algorithms = ALL
enable_rand = yes</code></pre></div><p>Подскажите, пожалуйста, с чем может быть связана данная ошибка?</p><p>P.S. пробовал как системную openssl, так и из состава Рутокен SDK<br />P.P.S. xca, на этой же системе, сертификаты на токене нормально выпускает ( ID c022ba7a6f620778 в выводе pkcs11-tool)</p>]]></content>
			<author>
				<name><![CDATA[sciram]]></name>
				<uri>https://forum.rutoken.ru/user/13314/</uri>
			</author>
			<updated>2023-03-13T17:12:44Z</updated>
			<id>https://forum.rutoken.ru/post/19826/#p19826</id>
		</entry>
</feed>
