<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[Форум Рутокен &mdash; C# Подписать текстовый документ.]]></title>
	<link rel="self" href="https://forum.rutoken.ru/feed/atom/topic/3243/" />
	<updated>2020-09-11T08:20:17Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.rutoken.ru/topic/3243/</id>
		<entry>
			<title type="html"><![CDATA[Re: C# Подписать текстовый документ.]]></title>
			<link rel="alternate" href="https://forum.rutoken.ru/post/14800/#p14800" />
			<content type="html"><![CDATA[<p>Ошибка вызвана тем, что у вас на Рутокене записаны ключи «КриптоПро» в режиме CSP.<br />С такими ключами библиотека PKCS#11 не работает. Вам нужны ключи формата PKCS#11.<br />Если вы используете «КриптоПро CSP» версии 5.0, вs можете генерировать ключи в режиме «<a href="https://dev.rutoken.ru/pages/viewpage.action?pageId=66815469/">Активный токен без защиты канала (rutoken_crypt_xxxx)</a>».<br />Или можете использовать для генерации Рутокен Плагин, например, на портале <a href="http://ra.rutoken.ru">ra.rutoken.ru</a></p>]]></content>
			<author>
				<name><![CDATA[Ксения Шаврова]]></name>
				<uri>https://forum.rutoken.ru/user/8982/</uri>
			</author>
			<updated>2020-09-11T08:20:17Z</updated>
			<id>https://forum.rutoken.ru/post/14800/#p14800</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: C# Подписать текстовый документ.]]></title>
			<link rel="alternate" href="https://forum.rutoken.ru/post/14790/#p14790" />
			<content type="html"><![CDATA[<p>Скриншоты<br /><span class="postimg"><a class="fancybox fancybox.image" rel="group" href="https://forum.rutoken.ru/uploads/images/2020/09/bceaed3c6b502edd11d8a46d1d5f3b58.png"><img class="fb_img" src="https://forum.rutoken.ru/uploads/previews/2020/09/bceaed3c6b502edd11d8a46d1d5f3b58.png" alt="" /></a></span> </p><p><span class="postimg"><a class="fancybox fancybox.image" rel="group" href="https://forum.rutoken.ru/uploads/images/2020/09/760ff2da26c3f4effb3c0ca5117a10c3.png"><img class="fb_img" src="https://forum.rutoken.ru/uploads/previews/2020/09/760ff2da26c3f4effb3c0ca5117a10c3.png" alt="" /></a></span></p>]]></content>
			<author>
				<name><![CDATA[Bkmz]]></name>
				<uri>https://forum.rutoken.ru/user/11549/</uri>
			</author>
			<updated>2020-09-10T14:16:15Z</updated>
			<id>https://forum.rutoken.ru/post/14790/#p14790</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: C# Подписать текстовый документ.]]></title>
			<link rel="alternate" href="https://forum.rutoken.ru/post/14778/#p14778" />
			<content type="html"><![CDATA[<p><strong>Bkmz</strong>, приветствую!</p><p>Обычно у сертификата и открытого/закрытого ключа одинаковые CKA_ID.<br />Приложите, пожалуйста, скриншот «Панель управления Рутокен» - вкладка «Сертификаты».<br />И уточните какую версию библиотеки PKCS#11 вы используете?</p>]]></content>
			<author>
				<name><![CDATA[Ксения Шаврова]]></name>
				<uri>https://forum.rutoken.ru/user/8982/</uri>
			</author>
			<updated>2020-09-10T07:39:01Z</updated>
			<id>https://forum.rutoken.ru/post/14778/#p14778</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: C# Подписать текстовый документ.]]></title>
			<link rel="alternate" href="https://forum.rutoken.ru/post/14767/#p14767" />
			<content type="html"><![CDATA[<p>Спасибо.<br />Можно еще ссылку на пример как из сертификата получить закрытый ключ чтобы собственно подписать документ.</p><p>В информацию получаю такую ошибку:<br />&nbsp; &nbsp; &nbsp; &nbsp; Subject Public Key Info:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Public Key Algorithm: 1.2.643.7.1.1.1.1<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Unable to load Public Key<br />6600:error:0609E09C:digital envelope routines:PKEY_SET_TYPE:unsupported algorithm:.\crypto\evp\p_lib.c:239:<br />6600:error:0B07706F:x509 certificate routines:X509_PUBKEY_get:unsupported algorithm:.\crypto\asn1\x_pubkey.c:148:</p><p>Повлияет ли она на использование данного сертификата?</p>]]></content>
			<author>
				<name><![CDATA[Bkmz]]></name>
				<uri>https://forum.rutoken.ru/user/11549/</uri>
			</author>
			<updated>2020-09-09T15:12:42Z</updated>
			<id>https://forum.rutoken.ru/post/14767/#p14767</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[Re: C# Подписать текстовый документ.]]></title>
			<link rel="alternate" href="https://forum.rutoken.ru/post/14764/#p14764" />
			<content type="html"><![CDATA[<p>Добрый день!</p><p>Попробуйте воспользоваться функцией GetCertificateInfoText()&nbsp; </p><p><a href="https://github.com/AktivCo/RutokenPkcs11Interop.Samples/blob/master/src/PKIExtensions.GetCertificateInfo-GOST34.10-2012-256/GetCertificateInfo-GOST34.10-2012-256.cs">https://github.com/AktivCo/RutokenPkcs1 … 012-256.cs</a></p>]]></content>
			<author>
				<name><![CDATA[Павел Анфимов]]></name>
				<uri>https://forum.rutoken.ru/user/7338/</uri>
			</author>
			<updated>2020-09-09T13:45:36Z</updated>
			<id>https://forum.rutoken.ru/post/14764/#p14764</id>
		</entry>
		<entry>
			<title type="html"><![CDATA[C# Подписать текстовый документ.]]></title>
			<link rel="alternate" href="https://forum.rutoken.ru/post/14763/#p14763" />
			<content type="html"><![CDATA[<p>Здравствуйте. <br />У меня задача найти сертификат в токене по какому то параметру который я могу увидеть в справочнике сертификатов.<br />Если через крипто про то я нахожу сертификат по понятному имени.</p><p>Не понимаю как мне найти сертификат через API на C#<br />в взял Пример - Standard.SignVerifyGOST34.10-2012-256</p><p>Дописал в нем код<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; List&lt;CKA&gt; valuesAsArray = new List&lt;CKA&gt;();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foreach (var v in Enum.GetValues(typeof(CKA)))<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; valuesAsArray.Add((CKA)v);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; int i = 1;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foreach (var f in privateKeys)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Print(valuesAsArray, session, f, $&quot;PRIVATE {i++}&quot;);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foreach (var f in publicKeys)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Print(valuesAsArray, session, f, $&quot;PUBLIC {i++}&quot;);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }</p><p> public static void Print(List&lt;CKA&gt; valuesAsArray, Session session, ObjectHandle key, string iteration)<br />&nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console.WriteLine($&quot;Begin {iteration}&quot;);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foreach (var v in valuesAsArray)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; try<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; List&lt;ObjectAttribute&gt; keyValue = session.GetAttributeValue(key, new List&lt;CKA&gt; { v });<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; foreach (var o in keyValue)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; switch (v)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case CKA.CKA_ISSUER:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case CKA.CKA_LABEL:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var s = o.GetValueAsString();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console.WriteLine($&quot;{v}={s}&quot;);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case CKA.CKA_START_DATE:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; case CKA.CKA_END_DATE:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var d = o.GetValueAsDateTime();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console.WriteLine($&quot;{v}={d}&quot;);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; default:<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; var b = o.GetValueAsByteArray();<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console.WriteLine($&quot;{v}={System.Text.Encoding.UTF8.GetString(b)} -&gt;&lt;- {Convert.ToBase64String(b)}&quot;);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; break;</p><p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; catch (Exception ex)<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; {<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console.WriteLine($&quot;Failed to get {v}={ex.Message}&quot;);<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; }<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Console.WriteLine($&quot;End {iteration}&quot;);</p><p>&nbsp; &nbsp; &nbsp; &nbsp; }<br />Запустил и он мне вообще практически никакой полезной информации не выдает. У меня никак не получается сопоставить данные сертификата с тем что я вижу в справочнике. Подскажите пожалуйста что делаю не так.<br />Begin PRIVATE 1<br />CKA_ID=????MP?? F9oT0h6NDL5NUO77Pjy+4uGbRfI=<br />Failed to get CKA_APPLICATION=Value of attribute CKA_APPLICATION could not be read<br />Failed to get CKA_VALUE=Value of attribute CKA_VALUE could not be read<br />Failed to get CKA_OBJECT_ID=Value of attribute CKA_OBJECT_ID could not be read<br />Failed to get CKA_CERTIFICATE_TYPE=Value of attribute CKA_CERTIFICATE_TYPE could not be read<br />Failed to get CKA_ISSUER=Value of attribute CKA_ISSUER could not be read<br />Failed to get CKA_SERIAL_NUMBER=Value of attribute CKA_SERIAL_NUMBER could not be read<br />Failed to get CKA_AC_ISSUER=Value of attribute CKA_AC_ISSUER could not be read<br />Failed to get CKA_OWNER=Value of attribute CKA_OWNER could not be read<br />Failed to get CKA_ATTR_TYPES=Value of attribute CKA_ATTR_TYPES could not be read<br />Failed to get CKA_TRUSTED=Value of attribute CKA_TRUSTED could not be read<br />Failed to get CKA_CERTIFICATE_CATEGORY=Value of attribute CKA_CERTIFICATE_CATEGORY could not be read<br />Failed to get CKA_JAVA_MIDP_SECURITY_DOMAIN=Value of attribute CKA_JAVA_MIDP_SECURITY_DOMAIN could not be read<br />Failed to get CKA_URL=Value of attribute CKA_URL could not be read<br />Failed to get CKA_HASH_OF_SUBJECT_PUBLIC_KEY=Value of attribute CKA_HASH_OF_SUBJECT_PUBLIC_KEY could not be read<br />Failed to get CKA_HASH_OF_ISSUER_PUBLIC_KEY=Value of attribute CKA_HASH_OF_ISSUER_PUBLIC_KEY could not be read<br />Failed to get CKA_CHECK_VALUE=Value of attribute CKA_CHECK_VALUE could not be read<br />Failed to get CKA_MODULUS=Value of attribute CKA_MODULUS could not be read<br />Failed to get CKA_MODULUS_BITS=Value of attribute CKA_MODULUS_BITS could not be read<br />Failed to get CKA_PUBLIC_EXPONENT=Value of attribute CKA_PUBLIC_EXPONENT could not be read<br />Failed to get CKA_PRIVATE_EXPONENT=Value of attribute CKA_PRIVATE_EXPONENT could not be read<br />Failed to get CKA_PRIME_1=Value of attribute CKA_PRIME_1 could not be read<br />Failed to get CKA_PRIME_2=Value of attribute CKA_PRIME_2 could not be read<br />Failed to get CKA_EXPONENT_1=Value of attribute CKA_EXPONENT_1 could not be read<br />Failed to get CKA_EXPONENT_2=Value of attribute CKA_EXPONENT_2 could not be read<br />Failed to get CKA_COEFFICIENT=Value of attribute CKA_COEFFICIENT could not be read<br />Failed to get CKA_PUBLIC_KEY_INFO=Value of attribute CKA_PUBLIC_KEY_INFO could not be read<br />Failed to get CKA_PRIME=Value of attribute CKA_PRIME could not be read<br />Failed to get CKA_SUBPRIME=Value of attribute CKA_SUBPRIME could not be read<br />Failed to get CKA_BASE=Value of attribute CKA_BASE could not be read<br />Failed to get CKA_PRIME_BITS=Value of attribute CKA_PRIME_BITS could not be read<br />Failed to get CKA_SUBPRIME_BITS=Value of attribute CKA_SUBPRIME_BITS could not be read<br />Failed to get CKA_VALUE_BITS=Value of attribute CKA_VALUE_BITS could not be read<br />Failed to get CKA_VALUE_LEN=Value of attribute CKA_VALUE_LEN could not be read</p>]]></content>
			<author>
				<name><![CDATA[Bkmz]]></name>
				<uri>https://forum.rutoken.ru/user/11549/</uri>
			</author>
			<updated>2020-09-09T13:27:53Z</updated>
			<id>https://forum.rutoken.ru/post/14763/#p14763</id>
		</entry>
</feed>
