{"id":187574,"date":"2013-07-23T20:21:03","date_gmt":"2013-07-23T16:21:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=187574"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=187574","title":{"rendered":"<span class=\"post_title\">\u0420\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441 \u0440\u0435\u0435\u0441\u0442\u0440\u043e\u043c \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d\u043d\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432<\/span>"},"content":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0435\u0441\u0442\u0440\u0430 \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d\u043d\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 <b>C#<\/b>, <b>OpenSSL<\/b> \u0438 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 <b>RouterOS<\/b> \u043d\u0430 \u0431\u0430\u0437\u0435 \u043e\u0431\u043e\u0440\u0443\u0434\u043e\u0432\u0430\u043d\u0438\u044f <b>MikroTik<\/b><\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/000\/ce9\/bbc\/000ce9bbc408fa57a3ad5945da0d4dcb.png\" alt=\"image\"\/><\/p>\n<p>  <a name=\"habracut\"><\/a><\/p>\n<h4>\u0412\u0432\u043e\u0434\u043d\u043e\u0435<\/h4>\n<p>  \u0412 \u0440\u0430\u0431\u043e\u0442\u0435 \u0431\u0443\u0434\u0435\u043c \u0440\u0443\u043a\u043e\u0432\u043e\u0434\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c\u0441\u044f <a href=\"http:\/\/zapret-info.gov.ru\/docs\/description_for_operators_2013-03-19v1.5.pdf\">\u043f\u0430\u043c\u044f\u0442\u043a\u043e\u0439 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0441\u0432\u044f\u0437\u0438<\/a>.<br \/>  \u0420\u0430\u0431\u043e\u0442\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0445 \u043f\u0443\u043d\u043a\u0442\u043e\u0432:  <\/p>\n<ol>\n<li><a href=\"#1\">\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430<\/a><\/li>\n<li><a href=\"#2\">\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0430 <b>OpenSSL<\/b><\/a><\/li>\n<li><a href=\"#3\">\u041f\u043e\u0434\u043f\u0438\u0441\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u0430<\/a><\/li>\n<li><a href=\"#4\">\u041f\u043e\u0434\u0430\u0447\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430<\/a><\/li>\n<li><a href=\"#5\">\u041e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0430 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430<\/a><\/li>\n<li><a href=\"#6\">\u0414\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u0432 \u0444\u0438\u043b\u044c\u0442\u0440 \u043d\u0430 MikroTik`\u0435<\/a><\/li>\n<\/ol>\n<p>  <a name=\"1\"><\/a><\/p>\n<h4>\u0421\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u0430<\/h4>\n<p>  \u0414\u043b\u044f \u043f\u043e\u0434\u0430\u0447\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0438 \u0438\u0437 \u0440\u0435\u0435\u0441\u0442\u0440\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u0438\u043a\u0440\u0435\u043f\u0438\u0442\u044c \u0444\u0430\u0439\u043b \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 <b>XML<\/b>. \u0424\u0430\u0439\u043b \u0438\u043c\u0435\u0435\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439 \u0432\u0438\u0434:<\/p>\n<pre><code class=\"xml\">&lt;?xml version=&quot;1.0&quot; encoding=&quot;windows-1251&quot;?&gt; &lt;request&gt;  &lt;requestTime&gt;2012-01-01T01:01:01.000+04:00&lt;\/requestTime&gt;  &lt;operatorName&gt;&lt;![CDATA[\u041d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430]]&gt;&lt;\/operatorName&gt;  &lt;inn&gt;1234567890&lt;\/inn&gt;  &lt;ogrn&gt;1234567890123&lt;\/ogrn&gt;  &lt;email&gt;email@email.ru&lt;\/email&gt; &lt;\/request&gt; <\/code><\/pre>\n<ul>\n<li><b>requestTime<\/b> \u2013 \u0434\u0430\u0442\u0430 \u0438 \u0432\u0440\u0435\u043c\u044f \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0441 \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u0437\u043e\u043d\u044b;<\/li>\n<li><b>operatorName<\/b> \u2013 \u043f\u043e\u043b\u043d\u043e\u0435 \u043d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0441\u0432\u044f\u0437\u0438;<\/li>\n<li><b>inn<\/b> \u2013 \u0418\u041d\u041d \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0441\u0432\u044f\u0437\u0438;<\/li>\n<li><b>ogrn<\/b> \u2013 \u041e\u0413\u0420\u041d \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430 \u0441\u0432\u044f\u0437\u0438;<\/li>\n<li><b>email<\/b> \u2013 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u044b\u0439 \u0430\u0434\u0440\u0435\u0441 \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u043e\u0433\u043e \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u0438\u0441\u0442\u0430, \u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0433\u043e \u0437\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043c\u0435\u0445\u0430\u043d\u0438\u0437\u043c\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0438; \u043c\u043e\u0436\u0435\u0442<br \/>  \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0434\u043b\u044f \u043e\u043f\u0435\u0440\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u0439 \u0441\u0432\u044f\u0437\u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0432\u043e\u0437\u043d\u0438\u043a\u043d\u043e\u0432\u0435\u043d\u0438\u044f \u0442\u0435\u0445\u043d\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u0432\u043e\u043f\u0440\u043e\u0441\u043e\u0432 \u0438\u043b\u0438 \u043f\u0440\u043e\u0431\u043b\u0435\u043c.<\/li>\n<\/ul>\n<p>  \u0413\u043b\u0430\u0432\u043d\u043e\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 <b>2012-01-01T01:01:01.000+04:00<\/b> \u0438 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0444\u0430\u0439\u043b \u0441 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u043e\u0439 <b>windows-1251<\/b>.<\/p>\n<p>  \u041a\u043e\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0433\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430 <b>C#<\/b>:<\/p>\n<pre><code class=\"cs\">public static String GeneratingRequest(String operatorName, String inn, String ogrn, String email) { \tString result = &quot;&lt;?xml version=\\&quot;1.0\\&quot; encoding=\\&quot;windows-1251\\&quot;?&gt;&quot;; \tresult += &quot;&lt;request&gt;&lt;requestTime&gt;&quot;; \tresult += DateTime.Now.ToString(&quot;yyyy-MM-ddTHH:mm:ss.fffzzz&quot;); \tresult += &quot;&lt;\/requestTime&gt;&lt;operatorName&gt;&quot;; \tresult += &quot;&lt;![CDATA[&quot; + operatorName + &quot;]]&gt;&quot;; \tresult += &quot;&lt;\/operatorName&gt;&lt;inn&gt;&quot;; \tresult += inn; \tresult += &quot;&lt;\/inn&gt;&lt;ogrn&gt;&quot;; \tresult += ogrn; \tresult += &quot;&lt;\/ogrn&gt;&lt;email&gt;&quot;; \tresult += email; \tresult += &quot;&lt;\/email&gt;&lt;\/request&gt;&quot;;   \treturn result; } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0444\u0430\u0439\u043b \u0432 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0435 <b>windows-1251<\/b>:  <\/p>\n<pre><code class=\"cs\">String Request = GeneratingRequest(&quot;\u041d\u0430\u0438\u043c\u0435\u043d\u043e\u0432\u0430\u043d\u0438\u0435 \u043e\u043f\u0435\u0440\u0430\u0442\u043e\u0440\u0430&quot;, &quot;1234567890&quot;, &quot;1234567890123&quot;, &quot;email@email.ru&quot;) StreamWriter swRequest = new StreamWriter(@&quot;C:\\request.xml&quot;, false, Encoding.GetEncoding(&quot;Windows-1251&quot;)); swRequest.Write(Request); swRequest.Close(); <\/code><\/pre>\n<p>  \u041f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0435\u0433\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u0442\u044c. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0447\u0435\u0441\u043a\u0438\u043c \u043f\u0430\u043a\u0435\u0442\u043e\u043c \u0441 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u043c \u0438\u0441\u0445\u043e\u0434\u043d\u044b\u043c \u043a\u043e\u0434\u043e\u043c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 <b>SSL\/TLS<\/b> \u2014 <b><a href=\"http:\/\/ru.wikipedia.org\/wiki\/OpenSSL\">OpenSSL<\/a><\/b>. \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c \u0438 \u043d\u0430\u0441\u0442\u0440\u043e\u0435\u043c.<\/p>\n<p>  <a name=\"2\"><\/a><\/p>\n<h4>OpenSSL<\/h4>\n<p>  \u041a\u0430\u0447\u0430\u0435\u043c \u043f\u0430\u043a\u0435\u0442 \u0441 \u044d\u0442\u043e\u0433\u043e \u0441\u0430\u0439\u0442\u0430 \u2014 <a href=\"http:\/\/slproweb.com\/products\/Win32OpenSSL.html\">slproweb.com<\/a>. \u0412 \u043c\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u0431\u044b\u043b <b>Win64 OpenSSL v1.0.1e<\/b>.<\/p>\n<p>  \u0414\u0430 \u044d\u0442\u0430 \u0441\u0431\u043e\u0440\u043a\u0430 \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u043e\u0433\u043e <b>Visual C++ 2008 Redistributables<\/b>, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043c\u043e\u0436\u043d\u043e \u0441\u043a\u0430\u0447\u0430\u0442\u044c \u0442\u0430\u043c \u0436\u0435.<br \/>  \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c. \u041f\u0440\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u0432 \u0434\u0438\u0430\u043b\u043e\u0433\u0435 <b>\u00abSelect Additional Tasks\u00bb<\/b> \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0432\u044b\u0431\u0440\u0430\u0442\u044c <b>\u00abThe OpenSSL\u201d binaries (\/bin) directory\u00bb<\/b> \u0431\u043e\u043b\u0435\u0435 \u0445\u0438\u0442\u0440\u043e\u0441\u0442\u0435\u0439 \u043d\u0435\u0442.<br \/>  \u0414\u0430\u043b\u0435\u0435 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u0432 \u043f\u0430\u043f\u043a\u0443 \u043a\u0443\u0434\u0430 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043b\u0438: <b>C:\/OpenSSL\/bin<\/b> \u0438 \u0440\u0435\u0434\u0430\u043a\u0442\u0438\u0440\u0443\u0435\u043c \u0444\u0430\u0439\u043b <b>openssl.cfg<\/b>. \u0412 \u043d\u0430\u0447\u0430\u043b\u043e \u0444\u0430\u0439\u043b\u0430 \u0434\u043e\u0431\u0430\u0432\u0438\u043c:<\/p>\n<p>  <code>openssl_conf = openssl_def<\/code><\/p>\n<p>  \u0412 \u043a\u043e\u043d\u0446\u0435:<br \/>  <code>[openssl_def]<\/code><br \/>  <code>engines=engine_section<\/code><\/p>\n<p>  <code>[engine_section]<\/code><br \/>  <code>gost=gost_section<\/code><\/p>\n<p>  <code>[gost_section]<\/code><br \/>  <code>engine_id=gost<\/code><br \/>  <code>dynamic_path = C:\/OpenSSL\/bin\/gost.dll<\/code><br \/>  <code>default_algorithms=ALL<\/code><\/p>\n<p>  \u0412\u0441\u0435 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0443\u0436\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u0441\u0440\u0435\u0434\u044b:<br \/>  <b>OPENSSL_CONF = C:\/OpenSSL\/bin\/openssl.cfg<\/b> \u2014 \u043f\u043e\u043b\u043d\u044b\u0439 \u043f\u0443\u0442\u044c \u043a <b>openssl.cfg<\/b><br \/>  \u043d\u0443 \u0438 \u0432 <b>PATH += C:\/OpenSSL\/bin;<\/b><\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u042d\u0426\u041f. \u041f\u0440\u0438\u043e\u0431\u0440\u0435\u0441\u0442\u0438 \u0435\u0435 \u043c\u043e\u0436\u043d\u043e \u0432 <a href=\"http:\/\/www.reestr-pki.ru\/tsl.html\">\u0434\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u043c \u0443\u0434\u043e\u0441\u0442\u043e\u0432\u0435\u0440\u044f\u044e\u0449\u0435\u043c \u0446\u0435\u043d\u0442\u0440\u0435<\/a>. \u041a\u043b\u044e\u0447 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 <b>PKCS#12<\/b> \u0438\u0437 \u043a\u0440\u0438\u043f\u0442\u043e\u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0432 Windows \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0443\u0442\u0438\u043b\u0438\u0442\u044b <a href=\"http:\/\/soft.lissi.ru\/products\/utils\/p12fromcsp\/\"><b>P12FromGostCSP<\/b><\/a><\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u0432 <b>PEM<\/b>. \u0412 <b>OpenSSL<\/b> \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0442\u0430\u043a (\u0447\u0435\u0440\u0435\u0437 \u043a\u043e\u043c\u0430\u043d\u0434\u043d\u0443\u044e \u0441\u0442\u0440\u043e\u043a\u0443 \u2014 \u043c\u043e\u0436\u0435\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0438\u0442\u044c \u043f\u0430\u0440\u043e\u043b\u044c \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0437\u0430\u0449\u0438\u0449\u0435\u043d \u041a\u043b\u044e\u0447 <b>PKCS#12<\/b>):<\/p>\n<pre><code class=\"bash\">openssl.exe pkcs12 -in C:\/key.pfx -out C:\/key.pem -nodes -clcerts <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/800\/100\/0fc\/8001000fcfa834f6547b5d5676cc58f3.png\" alt=\"image\"\/><\/p>\n<p>  \u0412\u0441\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u043c\u044b \u0432 \u0441\u043e\u0441\u0442\u043e\u044f\u043d\u0438\u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u0442\u044c \u043d\u0430\u0448 \u0437\u0430\u043f\u0440\u043e\u0441.<\/p>\n<p>  <a name=\"3\"><\/a><\/p>\n<h4>\u041f\u043e\u0434\u043f\u0438\u0441\u044c \u0437\u0430\u043f\u0440\u043e\u0441\u0430<\/h4>\n<p>  \u041f\u043e\u0434\u043f\u0438\u0441\u0430\u0442\u044c \u0437\u0430\u043f\u0440\u043e\u0441 \u043c\u043e\u0436\u043d\u043e \u0447\u0435\u0440\u0435\u0437 OpenSSL \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u043e\u0439:<\/p>\n<pre><code class=\"bash\">openssl.exe smime -sign -in C:\/request.xml -out C:\/request.xml.sign -signer C:\/key.pem -outform DER <\/code><\/pre>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/ae2\/55a\/303\/ae255a303c6b8ab1113b86ce4cd4139c.png\" alt=\"image\"\/><\/p>\n<p>  \u0420\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u0438 \u0444\u0430\u0439\u043b\u0430 \u043d\u0430 C#:<\/p>\n<pre><code class=\"cs\">public static Boolean SignRequest() { \tBoolean ret = true;   \tString OpenSSLPath = @&quot;C:\\OpenSSL\\bin&quot;; \tString RequestPath = @&quot;C:\\request.xml&quot;;    \tString SignRequestPath = @&quot;C:\\request.xml.sign&quot;; \tString KeyPEMPath = @&quot;C:\\key.pem&quot;;   \ttry \t{   \t\tProcess cmdProcess = new Process();   \t\t\/* \t\t * \u0421\u0442\u0440\u043e\u043a\u0443 \u043d\u0438\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0443\u0431\u0440\u0430\u0442\u044c  \t\t * \u0435\u0441\u043b\u0438 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f \u0441\u0440\u0435\u0434\u044b PATH \t\t * \u0438\u043c\u0435\u0435\u0442 \u043f\u0443\u0442\u044c \u0434\u043e OpenSSL \t\t *\/ \t\tcmdProcess.StartInfo.WorkingDirectory = OpenSSLPath; \t\tcmdProcess.StartInfo.FileName = &quot;openssl.exe&quot;; \t\tcmdProcess.StartInfo.Arguments = String.Format(&quot;smime -sign -in {0} -out {1} -signer {2} -outform DER&quot;, RequestPath, SignRequestPath, KeyPEMPath);   \t\tcmdProcess.StartInfo.CreateNoWindow = true; \t\tcmdProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; \t\tcmdProcess.Start(); \t\t\/\/\u0417\u0430\u0434\u0435\u0440\u0436\u043a\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0430 \u0442.\u043a. \u043d\u0443\u0436\u043d\u043e \u0434\u043e\u0436\u0434\u0430\u0442\u044c\u0441\u044f \u043a\u043e\u043d\u0446\u0430 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \t\tThread.Sleep(2500); \t} \tcatch (Exception) \t{ \t\tret = false; \t}   \treturn ret; } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u043d\u0430\u0448\u0443 \u0440\u0430\u0431\u043e\u0442\u0443. \u041f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u043b\u0438\u043d\u043d\u043e\u0441\u0442\u0438 \u042d\u041f: <a href=\"http:\/\/www.gosuslugi.ru\/pgu\/eds\/\">gosuslugi.ru<\/a>, \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u2014 <b>\u041f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u043b\u0438\u043d\u043d\u043e\u0441\u0442\u0438 \u044d\u043b\u0435\u043a\u0442\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430. \u042d\u041f \u2014 \u043e\u0442\u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u043d\u0430\u044f, \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 PKCS#7<\/b><\/p>\n<p>  \u041f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u043c \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u043a \u0437\u0430\u043f\u0440\u043e\u0441\u0443 \u0434\u0430\u043c\u043f\u0430 \u0440\u0435\u0435\u0441\u0442\u0440\u0430 \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d\u043d\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432.<\/p>\n<p>  <a name=\"4\"><\/a><\/p>\n<h4>\u041f\u043e\u0434\u0430\u0447\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0430 \u0440\u0435\u0435\u0441\u0442\u0440\u0430<\/h4>\n<p>  \u0412 \u0440\u0443\u0447\u043d\u0443\u044e \u0432\u0441\u0435 \u043f\u0440\u043e\u0441\u0442\u043e: <a href=\"http:\/\/zapret-info.gov.ru\/tooperators\/form\/\">\u0424\u043e\u0440\u043c\u0430 \u043f\u043e\u0434\u0430\u0447\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430<\/a>, \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0444\u0430\u0439\u043b \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u0435\u0433\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u044c (<b>C:\/request.xml<\/b> \u0438 <b>C:\/request.xml.sign<\/b>)<\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/d98\/713\/3f5\/d987133f52b4e367795e6130834b5e7f.png\" alt=\"image\"\/><\/p>\n<p>  \u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0442\u043e \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u2014 \u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430. \u041a\u0430\u043a \u043f\u0440\u0430\u0432\u0438\u043b\u043e \u0435\u0441\u043b\u0438 \u0432\u0441\u0435 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0442\u043e \u0440\u0435\u0435\u0441\u0442\u0440 \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0433\u0440\u0443\u0436\u0435\u043d \u043c\u0438\u043d\u0443\u0442 \u0447\u0435\u0440\u0435\u0437 5 \u0432 <b>ZIP<\/b> \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u0432 \u0430\u0440\u0445\u0438\u0432\u0435 \u0431\u0443\u0434\u0435\u0442 \u0434\u0432\u0430 \u0444\u0430\u0439\u043b\u0430 <b>dump.xml<\/b> \u2014 \u0434\u0430\u043c\u043f \u0440\u0435\u0435\u0441\u0442\u0440\u0430 \u0438 \u0435\u0433\u043e \u0446\u0438\u0444\u0440\u043e\u0432\u0430\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u044c.<\/p>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441. \u0414\u043b\u044f \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0438 \u0435\u0441\u0442\u044c \u0441\u0435\u0440\u0432\u0438\u0441 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0439 \u043f\u043e \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b\u0443 \u0434\u043e\u0441\u0442\u0443\u043f\u0430 <b><a href=\"http:\/\/ru.wikipedia.org\/wiki\/SOAP\">SOAP<\/a><\/b>, \u0430\u0434\u0440\u0435\u0441: <a href=\"http:\/\/www.zapret-info.gov.ru\/services\/OperatorRequest\/\">\u0441\u0435\u0440\u0432\u0438\u0441\u0430<\/a>. <b>WSDL \u0441\u0445\u0435\u043c\u0430<\/b> \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u0430 \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443: <b><a href=\"http:\/\/www.zapret-info.gov.ru\/services\/OperatorRequest\/?wsdl\">WSDL \u0441\u0445\u0435\u043c\u0430<\/a><\/b>.<\/p>\n<p>  \u0421\u0435\u0440\u0432\u0438\u0441 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 3-\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432:<\/p>\n<ul>\n<li><b>getLastDumpDate<\/b><br \/>  \u041c\u0435\u0442\u043e\u0434 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0439 \u043c\u0435\u0442\u043a\u0438 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0438 \u0438\u0437<br \/>  \u0440\u0435\u0435\u0441\u0442\u0440\u0430, <b>long<\/b> \u0444\u043e\u0440\u043c\u0430\u0442, \u0442\u0430\u043a \u0438 \u043d\u0435 \u043f\u043e\u043d\u044f\u043b \u043a\u0430\u043a \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c \u044d\u0442\u0443 \u0434\u0430\u0442\u0443, \u0445\u0440\u0430\u043d\u044e \u043a\u0430\u043a \u0435\u0441\u0442\u044c, \u0435\u0441\u043b\u0438 \u043a\u0442\u043e \u0432 \u043a\u0443\u0440\u0441\u0435, \u0442\u043e \u043f\u0440\u043e\u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0438\u0440\u0443\u0439\u0442\u0435. <\/li>\n<li><b>sendRequest<\/b><br \/>  \u041c\u0435\u0442\u043e\u0434 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043d\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0438 \u0438\u0437 \u0440\u0435\u0435\u0441\u0442\u0440\u0430, \u041f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 <b>requestFile<\/b> \u0438 <b>signatureFile<\/b> \u0432 <b>base64Binary<\/b> \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u2014 \u0444\u0430\u0439\u043b \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u0435\u0433\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0438 (<b>C:\/request.xml<\/b> \u0438 <b>C:\/request.xml.sign<\/b>) \u0412 \u043e\u0442\u0432\u0435\u0442 \u043f\u0440\u0438\u0441\u044b\u043b\u0430\u0435\u0442 <b>result<\/b> \u2014 \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 <b>boolean<\/b> \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u0438 \u0435\u0441\u043b\u0438 \u0432\u0441\u0435 \u0443\u0434\u0430\u0447\u043d\u043e, \u0442\u043e <b>code<\/b> \u2014 \u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0441\u0442\u0440\u043e\u043a\u0430 \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0443 \u0438\u0437 \u0440\u0435\u0435\u0441\u0442\u0440\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 <b>string<\/b>. \u0422\u0430\u043a \u0436\u0435 <b>resultComment<\/b> \u2014 \u041a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u043a \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0443 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 <b>string<\/b>. <\/li>\n<li><b>getResult<\/b><br \/>  \u041c\u0435\u0442\u043e\u0434 \u043f\u0440\u0435\u0434\u043d\u0430\u0437\u043d\u0430\u0447\u0435\u043d \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u2014 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0438 \u0438\u0437 \u0440\u0435\u0435\u0441\u0442\u0440\u0430, \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 <b>code<\/b> \u2014 \u0418\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0437\u0430\u043f\u0440\u043e\u0441\u0430, \u0441\u0442\u0440\u043e\u043a\u0430 \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0443 \u0438\u0437 \u0440\u0435\u0435\u0441\u0442\u0440\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 <b>string<\/b>. \u0412 \u043e\u0442\u0432\u0435\u0442 \u043f\u0440\u0438\u0441\u044b\u043b\u0430\u0435\u0442 <b>result<\/b> \u2014 \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 <b>boolean<\/b> \u0444\u043e\u0440\u043c\u0430\u0442\u0435 \u0438 \u0435\u0441\u043b\u0438 \u0432\u0441\u0435 \u0443\u0434\u0430\u0447\u043d\u043e, \u0442\u043e <b>registerZipArchive<\/b> \u2014 \u0424\u0430\u0439\u043b <b>zip-\u0430\u0440\u0445\u0438\u0432<\/b> \u0441 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u0438\u0437 \u0440\u0435\u0435\u0441\u0442\u0440\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 <b>base64Binary<\/b>. \u0422\u0430\u043a \u0436\u0435 <b>resultComment<\/b> \u2014 \u041a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0439 \u043a \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0443 \u043e\u0431\u0440\u0430\u0431\u043e\u0442\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 <b>string<\/b>. <\/li>\n<\/ul>\n<p>  \u041b\u043e\u0433\u0438\u043a\u0430 \u043f\u0440\u043e\u0441\u0442\u0430: \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0432\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043c\u0435\u0442\u043a\u0443 \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0435\u0433\u043e \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u0438\u044f \u0440\u0435\u0435\u0441\u0442\u0440\u0430, \u0435\u0441\u043b\u0438 \u043e\u043d \u0438\u0437\u043c\u0435\u043d\u0438\u043b\u0430\u0441\u044c, \u0442\u043e \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u0437\u0430\u043f\u0440\u043e\u0441 \u043d\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0438 \u0438\u0437 \u0440\u0435\u0435\u0441\u0442\u0440\u0430, \u0435\u0441\u043b\u0438 \u0432\u0441\u0435 \u0443\u0434\u0430\u0447\u043d\u043e, \u0442\u043e \u0447\u0435\u0440\u0435\u0437 5 \u043c\u0438\u043d\u0443\u0442 \u0437\u0430\u0431\u0438\u0440\u0430\u0435\u043c \u043d\u0430\u0448 \u0440\u0435\u0435\u0441\u0442\u0440 \u0438\u043b\u0438 \u0436\u0434\u0435\u043c \u0435\u0449\u0435 \u0447\u0443\u0442\u044c \u0447\u0443\u0442\u044c\u2026<\/p>\n<p>  \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 \u0440\u0435\u0441\u0443\u0440\u0441\u044b \u0441\u0435\u0440\u0432\u0438\u0441, \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u0430\u0434\u0440\u0435\u0441 WSDL \u0441\u0445\u0435\u043c\u044b.<br \/>  \u041a\u043e\u0434 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 <b>getLastDumpDate<\/b>, <b>sendRequest<\/b>, <b>getResult<\/b><\/p>\n<pre><code class=\"cs\">public static Int64 LastDumpDate() { \tInt64 lastDumpDate = 0;   \tusing (ChannelFactory&lt;ServiceReference.OperatorRequestPortType&gt; scf = new ChannelFactory&lt;ServiceReference.OperatorRequestPortType&gt;( \t\tnew BasicHttpBinding(), new EndpointAddress(&quot;http:\/\/zapret-info.gov.ru\/services\/OperatorRequest\/&quot;))) \t{ \t\tServiceReference.OperatorRequestPortType channel = scf.CreateChannel(); \t\tServiceReference.getLastDumpDateResponse glddr = channel.getLastDumpDate(new ServiceReference.getLastDumpDateRequest()); \t\tlastDumpDate = glddr.lastDumpDate; \t}   \treturn lastDumpDate; }   public static Boolean SendRequest(out String resultComment, out String code, Byte[] requestFile, Byte[] signatureFile) { \tBoolean result = false; \tcode = null;   \tusing (ChannelFactory&lt;ServiceReference.OperatorRequestPortType&gt; scf = new ChannelFactory&lt;ServiceReference.OperatorRequestPortType&gt;( \t\tnew BasicHttpBinding(), new EndpointAddress(&quot;http:\/\/zapret-info.gov.ru\/services\/OperatorRequest\/&quot;))) \t{ \t\tServiceReference.OperatorRequestPortType channel = scf.CreateChannel(); \t\tServiceReference.sendRequestRequestBody srrb = new ServiceReference.sendRequestRequestBody();   \t\tsrrb.requestFile = requestFile; \t\tsrrb.signatureFile = signatureFile;   \t\tServiceReference.sendRequestResponse srr = channel.sendRequest(new ServiceReference.sendRequestRequest(srrb));   \t\tresultComment = srr.Body.resultComment;   \t\tif (result = srr.Body.result) \t\t{ \t\t\tcode = srr.Body.code; \t\t} \t}   \treturn result; }   public static Boolean GetResult(out String resultComment, out Byte[] registerZipArchive, String code) { \tBoolean result = false; \tregisterZipArchive = null;   \tusing (ChannelFactory&lt;ServiceReference.OperatorRequestPortType&gt; scf = new ChannelFactory&lt;ServiceReference.OperatorRequestPortType&gt;( \t\tnew BasicHttpBinding(), new EndpointAddress(&quot;http:\/\/zapret-info.gov.ru\/services\/OperatorRequest\/&quot;))) \t{ \t\tServiceReference.OperatorRequestPortType channel = scf.CreateChannel(); \t\tServiceReference.getResultRequestBody grrb = new ServiceReference.getResultRequestBody();   \t\tgrrb.code = code;   \t\tServiceReference.getResultResponse grr = channel.getResult(new ServiceReference.getResultRequest(grrb));   \t\tresultComment = grr.Body.resultComment;   \t\tif (result = grr.Body.result) \t\t{ \t\t\tregisterZipArchive = grr.Body.registerZipArchive; \t\t} \t}   \treturn result; } <\/code><\/pre>\n<p>  \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440 \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441:<\/p>\n<pre><code class=\"cs\">String resultComment, code; if(SendRequest(out resultComment, out code, File.ReadAllBytes(@&quot;C:\/request.xml&quot;), File.ReadAllBytes(@&quot;C:\/request.xml.sign&quot;))) { \t\/\/... \u0412\u0441\u0435 \u0443\u0434\u0430\u0447\u043d\u043e } <\/code><\/pre>\n<p>  <a name=\"5\"><\/a><\/p>\n<h4>\u0420\u0430\u0437\u0431\u0438\u0440\u0430\u0435\u043c \u0434\u0430\u043c\u043f \u0440\u0435\u0435\u0441\u0442\u0440\u0430<\/h4>\n<p>  \u041d\u0430\u0434\u043e \u0440\u0430\u0441\u043f\u0430\u043a\u043e\u0432\u0430\u0442\u044c \u0430\u0440\u0445\u0438\u0432:  <\/p>\n<pre><code class=\"cs\">\/\/ Byte[] registerZipArchive - \u041f\u043e\u043b\u0443\u0447\u0435\u043d \u043f\u0440\u0438 \u0443\u0434\u0430\u0447\u043d\u043e\u0439 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0435 GetResult(); File.WriteAllBytes(@&quot;C:\/register.zip&quot;, registerZipArchive); ZipFile.ExtractToDirectory(@&quot;C:\/register.zip&quot;, @&quot;C:\/register&quot;); <\/code><\/pre>\n<h5>\u041f\u0430\u0440\u0441\u0438\u043c XML<\/h5>\n<p>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0434\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u0430: \u043f\u0435\u0440\u0432\u044b\u0439 <b>RegisterDump<\/b> \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u043f\u043e\u043b\u0435 <b>UpdateTime<\/b> \u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u043e\u0431\u044a\u0435\u043a\u0442\u043e\u0432 <b>content<\/b>, \u0412\u0442\u043e\u0440\u043e\u0439 <b>ItemRegisterDump<\/b> \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u043e\u0434\u0438\u043d \u043e\u0431\u044a\u0435\u043a\u0442 <b>content<\/b> \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u043f\u043e\u043b\u044f\u043c\u0438.<\/p>\n<pre><code class=\"cs\">public class RegisterDump { \t\/* \t * &lt;reg:register updateTime=&quot;2013-07-15T10:05:00+04:00&quot; xmlns:reg=&quot;http:\/\/rsoc.ru&quot; xmlns:tns=&quot;http:\/\/rsoc.ru&quot;&gt; \t *    &lt;content&gt;&lt;\/content&gt; \t *    &lt;content&gt;&lt;\/content&gt; \t *       ... \t *    &lt;content&gt;&lt;\/content&gt; \t * &lt;\/reg:register&gt; \t *\/   \tpublic List&lt;ItemRegisterDump&gt; Items { get; set; } \tpublic String UpdateTime { get; set; }   \tpublic RegisterDump() \t{ \t\tthis.Items = new List&lt;ItemRegisterDump&gt;(); \t\tthis.UpdateTime = String.Empty; \t}   \tpublic RegisterDump(String UpdateTime, List&lt;ItemRegisterDump&gt; Items) \t{ \t\tthis.Items = Items; \t\tthis.UpdateTime = UpdateTime; \t} }   public class ItemRegisterDump { \t\/* \t * &lt;content id=&quot;60&quot; includeTime=&quot;2013-01-12T16:33:38&quot;&gt; \t *    &lt;decision date=&quot;2013-11-03&quot; number=&quot;\u041c\u0418-6&quot; org=&quot;\u0420\u043e\u0441\u041a\u043e\u0441\u041c\u043e\u043f\u0441\u041f\u043e\u043f\u0441&quot;\/&gt; \t *    &lt;url&gt;&lt;![CDATA[http:\/\/chelaxe.ru\/blacklist\/]]&gt;&lt;\/url&gt; \t *    &lt;domain&gt;&lt;![CDATA[chelaxe.ru]]&gt;&lt;\/domain&gt; \t *    &lt;ip&gt;123.45.67.89&lt;\/ip&gt; \t * &lt;\/content&gt; \t *\/   \tpublic String id { get; set; } \tpublic String includeTime { get; set; }   \tpublic String date { get; set; } \tpublic String number { get; set; } \tpublic String org { get; set; }   \tpublic String url { get; set; } \tpublic String domain { get; set; } \tpublic String ip { get; set; }   \tpublic ItemRegisterDump() \t{ \t\tid = String.Empty; \t\tincludeTime = String.Empty;   \t\tdate = String.Empty; \t\tnumber = String.Empty; \t\torg = String.Empty;   \t\turl = String.Empty; \t\tdomain = String.Empty; \t\tip = String.Empty; \t} } <\/code><\/pre>\n<p>  \u041f\u0430\u0440\u0441\u0438\u043c:<\/p>\n<pre><code class=\"cs\">RegisterDump Register = new RegisterDump(); String dumpfile = @&quot;C:\/register\/dump.xml&quot;;   XmlDocument xmlDoc = new XmlDocument(); xmlDoc.Load(dumpfile);   Register.UpdateTime = xmlDoc.GetElementsByTagName(&quot;reg:register&quot;)[0].Attributes.GetNamedItem(&quot;updateTime&quot;).InnerText; XmlNodeList content = xmlDoc.GetElementsByTagName(&quot;content&quot;);   for (int i = 0; i &lt; content.Count; i++) { \tXmlNodeList nodechild = content[i].ChildNodes;   \tItemRegisterDump item = new ItemRegisterDump();   \titem.id = content[i].Attributes.GetNamedItem(&quot;id&quot;).InnerText; \titem.includeTime = content[i].Attributes.GetNamedItem(&quot;includeTime&quot;).InnerText;   \titem.date = nodechild[0].Attributes.GetNamedItem(&quot;date&quot;).InnerText; \titem.number = nodechild[0].Attributes.GetNamedItem(&quot;number&quot;).InnerText; \titem.org = nodechild[0].Attributes.GetNamedItem(&quot;org&quot;).InnerText;   \titem.url = nodechild[1].InnerText; \titem.domain = nodechild[2].InnerText; \titem.ip = nodechild[3].InnerText;   \tRegister.Items.Add(item); } <\/code><\/pre>\n<p>  \u0422\u0435\u043f\u0435\u0440\u044c \u0431\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u043c \u0432\u0441\u0435 \u044d\u0442\u043e \u0434\u043e\u0431\u0440\u043e \u043d\u0430 \u043d\u0430\u0448\u0435\u043c MikroTik.<\/p>\n<p>  <a name=\"6\"><\/a><\/p>\n<h4>\u0411\u043b\u043e\u043a\u0438\u0440\u0443\u0435\u043c \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c MikroTik<\/h4>\n<p>  \u0414\u0435\u043b\u0430\u0435\u043c \u043c\u044b \u044d\u0442\u043e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e <a href=\"http:\/\/wiki.mikrotik.com\/wiki\/Manual:IP\/Firewall\/L7\"><b>layer7-protocol<\/b><\/a> \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0432 <a href=\"http:\/\/wiki.mikrotik.com\/wiki\/Manual:IP\/Firewall\/Filter\">\u0444\u0438\u043b\u044c\u0442\u0440\u044b<\/a>.<\/p>\n<p>  \u0412\u043e\u0442 \u043f\u0440\u0438\u043c\u0435\u0440:<br \/>  <code>\/ip firewall layer7-protocol add name=12 comment=register regexp=^.+(chelaxe.ru).*$<\/code><br \/>  <code>\/ip firewall filter add action=drop chain=forward disabled=no dst-port=80 layer7-protocol=12 protocol=tcp src-address=192.168.0.0\/24 comment=register<\/code><\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/9cf\/c97\/26c\/9cfc9726ce505db15ab4ea1d7bee9305.png\" alt=\"image\"\/><br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/1aa\/175\/515\/1aa1755151bee6188e7732ae86d88771.png\" alt=\"image\"\/><br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/95a\/b6f\/834\/95ab6f8345d8535f0cabc10744298769.png\" alt=\"image\"\/><br \/>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/c56\/8a8\/1df\/c568a81dfe6b9ee07974f9fcdfa3034d.png\" alt=\"image\"\/><\/p>\n<p>  \u0412\u0441\u0435 \u0442\u0435\u043f\u0435\u0440\u044c \u0432\u0441\u0435 \u043f\u0430\u043a\u0435\u0442\u044b \u0434\u043b\u044f \u043f\u043e\u0434\u0441\u0435\u0442\u0438 <b>192.168.0.0\/24<\/b> \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0449\u0438\u0435 \u043f\u043e <b>TCP<\/b> \u043d\u0430 <b>80<\/b> \u043f\u043e\u0440\u0442 \u0441 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435\u043c \u043f\u043e\u0434\u0441\u0442\u0440\u043e\u043a\u0438 <b>chelaxe.ru<\/b> \u043e\u0442\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u044e\u0442\u0441\u044f.<br \/>  \u0412 \u043a\u043e\u043c\u043c\u0435\u043d\u0442\u0430\u0440\u0438\u0438 \u043d\u0430\u0434\u043f\u0438\u0441\u044c <b>register<\/b> \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435 \u0441 \u043f\u0440\u043e\u0441\u0442\u0430. \u041e\u043d\u0430 \u043d\u0443\u0436\u043d\u0430 \u043d\u0430\u043c \u0431\u0443\u0434\u0435\u0442 \u0434\u043b\u044f \u0443\u0434\u0430\u043b\u0435\u043d\u0438\u044f \u0432\u0441\u0435\u0445 \u043f\u0440\u0430\u0432\u0438\u043b \u043f\u0440\u0435\u0436\u0434\u0435 \u0447\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043e\u0431\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0435.<\/p>\n<p>  \u0412\u043e\u0442 \u0441\u043a\u0440\u0438\u043f\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0443\u0434\u0430\u043b\u0438\u0442 \u0432\u0441\u0435 \u0437\u0430\u043f\u0438\u0441\u0438:<\/p>\n<p>  <code>\/ip firewall layer7-protocol remove [find comment=register]<\/code><br \/>  <code>\/ip firewall filter remove [find comment=register]<\/code><\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/723\/14a\/51b\/72314a51b2064c7b6aa6dd34e8efff83.png\" alt=\"image\"\/><\/p>\n<p>  \u041e\u0431\u0449\u0435\u043d\u0438\u0435 \u0441 MikroTik \u0440\u043e\u0443\u0442\u0435\u0440\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u043e\u043c <a href=\"http:\/\/wiki.mikrotik.com\/wiki\/Manual:API\">API<\/a>, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u0441 \u043f\u0440\u0438\u043c\u0435\u0440\u0430\u043c\u0438 \u043d\u0430\u043c \u0443\u0436\u0435 \u043d\u0430\u043f\u0438\u0441\u0430\u043b\u0438: <a href=\"http:\/\/wiki.mikrotik.com\/wiki\/API_in_C_Sharp\">wiki\/API C#<\/a><\/p>\n<p>  \u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u044d\u0442\u0443 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 (\u043a\u043b\u0430\u0441\u0441) \u0438 \u043f\u0440\u0438\u043d\u0446\u0438\u043f \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043a\u043e\u043d\u0442\u0435\u043d\u0442\u0430 \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043d\u043d\u044b\u0439 \u0432\u044b\u0448\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u0443\u0435\u043c \u0432\u0441\u0435 \u044d\u0442\u043e \u043d\u0430 C#<\/p>\n<pre><code class=\"cs\">public static Boolean AddFilterL7(String ip, String username, String password, RegisterDump dump, String SRCAddress) { \tBoolean ret = true;   \ttry \t{ \t\t\/\/\u041a\u043b\u0430\u0441\u0441 MK \u0441\u043c\u043e\u0442\u0440\u0438 \u0437\u0434\u0435\u0441\u044c http:\/\/wiki.mikrotik.com\/wiki\/API_in_C_Sharp \t\tMK mikrotik = new MK(IPAddress.Parse(ip).ToString());   \t\tif (mikrotik.Login(username, password)) \t\t{\t\t\t \t\t\tmikrotik.Send(&quot;\/system\/script\/add&quot;); \t\t\tmikrotik.Send(&quot;=name=cleaner&quot;); \t\t\tmikrotik.Send(&quot;=source=\/ip firewall layer7-protocol remove [find comment=register]\\n\/ip firewall filter remove [find comment=register]&quot;, true);   \t\t\tmikrotik.Send(&quot;\/system\/script\/run&quot;); \t\t\tmikrotik.Send(&quot;=number=cleaner&quot;, true);   \t\t\t\/* Cleaner \t\t\t * \/ip firewall layer7-protocol remove [find comment=register] \t\t\t * \/ip firewall filter remove [find comment=register] \t\t\t *\/   \t\t\t\/\/\u0416\u0434\u0435\u043c \u043f\u043e\u043a\u0430 \u0432\u0441\u0435 \u0441\u0442\u0430\u0440\u044b\u0435 \u0437\u0430\u043f\u0438\u0441\u0438 \u0443\u0434\u0430\u043b\u044f\u0442\u0441\u044f \t\t\tThread.Sleep(1000);   \t\t\tforeach (ItemRegisterDump item in dump.Items) \t\t\t{ \t\t\t\t\/\/\u0416\u0434\u0435\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b MikroTik \u043d\u0435 \u0437\u0430\u0445\u043b\u0435\u0431\u043d\u0443\u043b\u0441\u044f \t\t\t\tThread.Sleep(100);   \t\t\t\t\/\/ \/ip firewall layer7-protocol add name=12 comment=register regexp=^.+(chelaxe.ru).*$ \t\t\t\tmikrotik.Send(&quot;\/ip\/firewall\/layer7-protocol\/add&quot;); \t\t\t\tmikrotik.Send(&quot;=name=&quot; + item.id); \t\t\t\tmikrotik.Send(&quot;=comment=register&quot;); \t\t\t\tmikrotik.Send(&quot;=regexp=^.+(&quot; + item.domain + &quot;).*$&quot;, true);   \t\t\t\t\/\/\u0416\u0434\u0435\u043c \u043d\u0435\u043c\u043d\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b MikroTik \u043d\u0435 \u0437\u0430\u0445\u043b\u0435\u0431\u043d\u0443\u043b\u0441\u044f \t\t\t\tThread.Sleep(100);   \t\t\t\t\/\/ \/ip firewall filter add action=drop chain=forward disabled=no dst-port=80 layer7-protocol=12 protocol=tcp src-address=192.168.0.0\/24 comment=register \t\t\t\tmikrotik.Send(&quot;\/ip\/firewall\/filter\/add&quot;); \t\t\t\tmikrotik.Send(&quot;=action=drop&quot;); \t\t\t\tmikrotik.Send(&quot;=chain=forward&quot;); \t\t\t\tmikrotik.Send(&quot;=disabled=no&quot;); \t\t\t\tmikrotik.Send(&quot;=dst-port=80&quot;); \t\t\t\tmikrotik.Send(&quot;=layer7-protocol=&quot; + item.id); \t\t\t\tmikrotik.Send(&quot;=protocol=tcp&quot;); \t\t\t\tmikrotik.Send(&quot;=src-address=&quot; + SRCAddress); \t\t\t\tmikrotik.Send(&quot;=comment=register&quot;, true);                         \t\t\t} \t\t}   \t\tThread.Sleep(200); \t\tmikrotik.Close(); \t} \tcatch (Exception) \t{ \t\tret = false; \t}   \treturn ret; } <\/code><\/pre>\n<p>  \u041d\u0443 \u0432\u043e\u0442 \u0438 \u0432\u0441\u0435.<\/p>\n<p>  \u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b <a href=\"https:\/\/github.com\/chelaxe\/BlackList\">\u0437\u0434\u0435\u0441\u044c<\/a>. \t\t\t<\/p>\n<div class=\"clear\"><\/div>\n<\/p><\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"http:\/\/habrahabr.ru\/post\/187574\/\"> http:\/\/habrahabr.ru\/post\/187574\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div class=\"content html_format\"> \t\t\t\u0410\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0440\u0435\u0435\u0441\u0442\u0440\u0430 \u0437\u0430\u043f\u0440\u0435\u0449\u0435\u043d\u043d\u044b\u0445 \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0432 \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 <b>C#<\/b>, <b>OpenSSL<\/b> \u0438 \u0444\u0438\u043b\u044c\u0442\u0440\u0430\u0446\u0438\u044f \u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0430\u043c\u0438 <b>RouterOS<\/b> \u043d\u0430 \u0431\u0430\u0437\u0435 \u043e\u0431\u043e\u0440\u0443\u0434\u043e\u0432\u0430\u043d\u0438\u044f <b>MikroTik<\/b><\/p>\n<p>  <img decoding=\"async\" src=\"http:\/\/habrastorage.org\/storage2\/000\/ce9\/bbc\/000ce9bbc408fa57a3ad5945da0d4dcb.png\" alt=\"image\"\/><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-187574","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/187574","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=187574"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/187574\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=187574"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=187574"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=187574"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}