{"id":289354,"date":"2018-09-13T15:45:02","date_gmt":"2018-09-13T11:45:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=289354"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=289354","title":{"rendered":"\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u041a\u0440\u0438\u043f\u0442\u043e\u041f\u0440\u043e \u0432 Mono"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\n<p>\u0412 \u0441\u0432\u044f\u0437\u0438 \u0441 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u043c \u043d\u0430 Linux \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043d\u0430\u0448\u0438\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0439 \u043d\u0430 C# \u0432 Mono. \u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0443\u0441\u0438\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u042d\u0426\u041f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u043c\u0438 \u0437\u0430\u0434\u0430\u0447 \u0431\u044b\u043b\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0413\u041e\u0421\u0422\u043e\u0432\u044b\u0445 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u043e\u0442 \u041a\u0440\u0438\u043f\u0442\u043e\u041f\u0440\u043e \u0432 mono. \u0421\u0430\u043c \u041a\u0440\u0438\u043f\u0442\u043e\u041f\u0440\u043e \u0443\u0436\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0434\u0430\u0432\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b <a href=\"https:\/\/www.cryptopro.ru\/products\/csp\/compare\">CSP <\/a>\u043f\u043e\u0434 Linux, \u043d\u043e \u043f\u0435\u0440\u0432\u0430\u044f \u0436\u0435 \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0430, \u0447\u0442\u043e \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0438 Mono (\u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0435 \u0442\u0435\u043c, \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u0432 \u0431\u0430\u0437\u043e\u0432\u043e\u043c .Net \u2014 X509Store, X509Certificate2 \u0438 \u043f\u0440\u043e\u0447.) \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441 \u0413\u041e\u0421\u0422\u043e\u0432\u044b\u043c\u0438 \u043a\u043b\u044e\u0447\u0430\u043c\u0438, \u043e\u043d\u0438 \u0434\u0430\u0436\u0435 \u043d\u0435 \u0432\u0438\u0434\u044f\u0442 \u0438\u0445 \u0432 \u0441\u0432\u043e\u0438\u0445 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430\u0445. \u0412 \u0441\u0438\u043b\u0443 \u044d\u0442\u043e\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0435\u0439 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0447\u0435\u0440\u0435\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u041a\u0440\u0438\u043f\u0442\u043e\u041f\u0440\u043e.<\/p>\n<p>  <a name=\"habracut\"><\/a>  <\/p>\n<h2>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430<\/h2>\n<p>  <\/p>\n<p>\u041f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c \u043a\u0430\u043a \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043a\u043e\u0434, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 \u0438 \u0443\u0431\u0435\u0434\u0438\u0442\u0441\u044f \u0447\u0442\u043e \u043e\u043d \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442.<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<p>\u041a\u043e\u043c\u043f\u043e\u043d\u0435\u043d\u0442 \u041a\u0440\u0438\u043f\u0442\u043e\u041f\u0440\u043e CSP \u0432\u0435\u0440\u0441\u0438\u0438 3.9 \u0431\u044b\u043b \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u0432 Centos 7 \u0432 \u043f\u0430\u043f\u043a\u0443 \/opt\/cprocsp. \u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0431\u044b\u043b\u043e \u043a\u043e\u043d\u0444\u043b\u0438\u043a\u0442\u043e\u0432 \u043c\u0435\u0436\u0434\u0443 \u0443\u0442\u0438\u043b\u0438\u0442\u0430\u043c\u0438 mono \u0438 \u041a\u0440\u0438\u043f\u0442\u043e\u041f\u0440\u043e, \u0438\u043c\u0435\u044e\u0449\u0438\u0445 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, certmgr), \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u044b\u0435 \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u044f \u043d\u0435 \u0441\u0442\u0430\u043b\u0438 \u0432\u043d\u043e\u0441\u0438\u0442\u044c \u043f\u0443\u0442\u044c \u0434\u043e \u043f\u0430\u043f\u043a\u0438 \u0438 \u0432\u0441\u0435 \u0443\u0442\u0438\u043b\u0438\u0442\u044b \u0432\u044b\u0437\u044b\u0432\u0430\u043b\u0438\u0441\u044c \u043f\u043e \u043f\u043e\u043b\u043d\u043e\u043c\u0443 \u043f\u0443\u0442\u0438.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u0435\u043b\u0435\u0439:<br \/>  <code>\/opt\/cprocsp\/bin\/amd64\/csptest -enum -info -type PP_ENUMREADERS | iconv -f cp1251<\/code><\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0441\u0440\u0435\u0434\u0438 \u0441\u043f\u0438\u0441\u043a\u0430 \u043d\u0435\u0442 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0442\u0435\u043b\u044f \u0441 \u043f\u0430\u043f\u043a\u0438 \u043d\u0430 \u0434\u0438\u0441\u043a\u0435 (HDIMAGE) \u0441\u0442\u0430\u0432\u0438\u043c \u0435\u0433\u043e:<br \/>  <code>\/opt\/cprocsp\/sbin\/amd64\/cpconfig -hardware reader -add HDIMAGE store<\/code><\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u044b \u0432\u0438\u0434\u0430 &#8216;\\\\.\\HDIMAGE\\{\u0438\u043c\u044f \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430}&#8217; \u043f\u0443\u0442\u0435\u043c \u043b\u0438\u0431\u043e \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u043d\u043e\u0432\u043e\u0433\u043e \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u0441 \u043a\u043b\u044e\u0447\u0430\u043c\u0438:<br \/>  <code>\/opt\/cprocsp\/bin\/amd64\/csptest -keyset -provtype 75 -newkeyset -cont '\\\\.\\HDIMAGE\\test'<\/code><\/p>\n<p>  <\/p>\n<p>\u043b\u0438\u0431\u043e \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044f \u043f\u0430\u043f\u043a\u0443 \/var\/opt\/cprocsp\/keys\/root\/{\u0438\u043c\u044f \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430}.000, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0440\u0430\u0441\u043f\u043e\u043b\u0430\u0433\u0430\u0435\u0442\u0441\u044f \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u0444\u0430\u0439\u043b\u043e\u0432 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u041a\u0440\u0438\u043f\u0442\u043e\u041f\u0440\u043e (*.key, *.mask, \u0438 \u043f\u0440\u043e\u0447.).<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430 \u043c\u043e\u0436\u043d\u043e \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432:<br \/>  <code>\/opt\/cprocsp\/bin\/amd64\/certmgr -inst mMy -cont '\\\\.\\HDIMAGE\\{\u0438\u043c\u044f \u043a\u043e\u043d\u0442\u0435\u0439\u043d\u0435\u0440\u0430}'<\/code><\/p>\n<p>  <\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u043a\u043e\u043c\u0430\u043d\u0434\u044b:<br \/>  <code>\/opt\/cprocsp\/bin\/amd64\/certmgr -list mMy<\/code><\/p>\n<p>  <\/p>\n<p>\u0420\u0430\u0431\u043e\u0442\u0443 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<br \/>  <code>\/opt\/cprocsp\/bin\/amd64\/cryptcp \u2013 sign -norev -thumbprint {\u043e\u0442\u043f\u0435\u0447\u0430\u0442\u043e\u043a} {\u0444\u0430\u0439\u043b} {\u0444\u0430\u0439\u043b \u043f\u043e\u0434\u043f\u0438\u0441\u0438}<\/code><br \/>  <code>\/opt\/cprocsp\/bin\/amd64\/cryptcp \u2013 verify -norev {\u0444\u0430\u0439\u043b \u043f\u043e\u0434\u043f\u0438\u0441\u0438}<\/code><\/p>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0441 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u043c \u0432\u0441\u0435 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e, \u0442\u043e \u043c\u043e\u0436\u043d\u043e \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u0438\u0442\u044c \u043a \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044e \u0432 \u043a\u043e\u0434\u0435.<\/p>\n<p>  <\/div>\n<\/div>\n<p>  <\/p>\n<h2>\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0432 \u043a\u043e\u0434\u0435<\/h2>\n<p>  <\/p>\n<p>\u041d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430 \u0432 Linux \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u043b\u0430 \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0442\u044c \u0444\u0443\u043d\u043a\u0446\u0438\u043e\u043d\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438 \u0432 \u0441\u0440\u0435\u0434\u0435 Windows, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432\u043d\u0435\u0448\u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0435\u0439 \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u043b\u0430 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u0447\u0435\u0440\u0435\u0437 \u043e\u0431\u0449\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0432\u0438\u0434\u0430 \u00abbyte[] SignData(byte[] _arData, X509Certificate2 _pCert)\u00bb, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u043b\u0438 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u043a\u0430\u043a \u0432 Linux, \u0442\u0430\u043a \u0438 \u0432 Windows.<\/p>\n<p>  <\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0438 \u043e\u043a\u0430\u0437\u0430\u043b\u0441\u044f \u0443\u0434\u0430\u0447\u043d\u044b\u043c, \u0442.\u00a0\u043a. \u041a\u0440\u0438\u043f\u0442\u043e\u041f\u0440\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0443 \u00ablibcapi20.so\u00bb \u043a\u043e\u0442\u043e\u0440\u0430\u044f \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e \u043c\u0438\u043c\u0438\u043a\u0440\u0438\u0440\u0443\u0435\u0442 \u043f\u043e\u0434 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 Windows \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u2014 \u00abcrypt32.dll\u00bb \u0438 \u00abadvapi32.dll\u00bb. \u0412\u043e\u0437\u043c\u043e\u0436\u043d\u043e, \u043a\u043e\u043d\u0435\u0447\u043d\u043e, \u043d\u0435 \u0446\u0435\u043b\u0438\u043a\u043e\u043c, \u043d\u043e \u0432\u0441\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0438 \u0442\u0430\u043c \u0432 \u043d\u0430\u043b\u0438\u0447\u0438\u0438, \u0438 \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0434\u0432\u0430 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0445 \u043a\u043b\u0430\u0441\u0441\u0430 \u00abWCryptoAPI\u00bb \u0438 \u00abLCryptoAPI\u00bb \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u0438\u043c\u043f\u043e\u0440\u0442\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0439 \u043d\u0430\u0431\u043e\u0440 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">[DllImport(LIBCAPI20, SetLastError = true)] internal static extern bool CertCloseStore(IntPtr _hCertStore, uint _iFlags); <\/code><\/pre>\n<p>  <\/p>\n<p>\u0421\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u043c\u043e\u0436\u043d\u043e \u043b\u0438\u0431\u043e \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e, \u043b\u0438\u0431\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u0430\u0439\u0442\u043e\u043c <a href=\"https:\/\/pinvoke.net\/\">pinvoke<\/a>, \u043b\u0438\u0431\u043e \u0441\u043a\u043e\u043f\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432 .Net (\u043a\u043b\u0430\u0441\u0441 <a href=\"https:\/\/referencesource.microsoft.com\/#System\/security\/system\/security\/cryptography\/cryptoapi.cs,1922\">CAPISafe<\/a>). \u0418\u0437 \u044d\u0442\u043e\u0433\u043e \u0436\u0435 \u043c\u043e\u0434\u0443\u043b\u044f \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0447\u0435\u0440\u043f\u043d\u0443\u0442\u044c \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442\u044b \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0435 \u0441 \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0435\u0439, \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0431\u043b\u0435\u0433\u0447\u0430\u044e\u0442 \u0436\u0438\u0437\u043d\u044c \u043f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0432\u043d\u0435\u0448\u043d\u0438\u043c\u0438 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430\u043c\u0438.<\/p>\n<p>  <\/p>\n<p>\u0410 \u0437\u0430\u0442\u0435\u043c \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043b\u0430\u0441\u0441 \u00abUCryptoAPI\u00bb \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u0431\u0443\u0434\u0435\u0442 \u0432\u044b\u0437\u044b\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u0434\u0432\u0443\u0445 \u043a\u043b\u0430\u0441\u0441\u043e\u0432:<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">\/**&lt;summary&gt;\u0417\u0430\u043a\u0440\u044b\u0442\u044c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435&lt;\/summary&gt; * &lt;param name=&quot;_iFlags&quot;&gt;\u0424\u043b\u0430\u0433\u0438 (\u043d\u0443\u0436\u043d\u043e \u0441\u0442\u0430\u0432\u0438\u0442\u044c 0)&lt;\/param&gt; * &lt;param name=&quot;_hCertStore&quot;&gt;\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432&lt;\/param&gt; * &lt;returns&gt;\u0424\u043b\u0430\u0433 \u0443\u0441\u043f\u0435\u0448\u043d\u043e\u0441\u0442\u0438 \u0437\u0430\u043a\u0440\u044b\u0442\u0438\u044f \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430&lt;\/returns&gt; * **\/ internal static bool CertCloseStore(IntPtr _hCertStore, uint _iFlags) {     if (fIsLinux)         return LCryptoAPI.CertCloseStore(_hCertStore, _iFlags);     else         return WCryptoAPI.CertCloseStore(_hCertStore, _iFlags); } \/**&lt;summary&gt;\u041d\u0430\u0445\u043e\u0434\u0438\u043c\u0441\u044f \u0432 \u043b\u0438\u043d\u0443\u043a\u0441\u0435&lt;\/summary&gt;**\/ public static bool fIsLinux {     get {         int iPlatform = (int) Environment.OSVersion.Platform;         return (iPlatform == 4) || (iPlatform == 6) || (iPlatform == 128);     } } <\/code><\/pre>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0441\u0430 UCryptoAPI \u043c\u043e\u0436\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043f\u043e\u0447\u0442\u0438 \u0435\u0434\u0438\u043d\u044b\u0439 \u043a\u043e\u0434 \u043f\u043e\u0434 \u043e\u0431\u0435 \u0441\u0438\u0441\u0442\u0435\u043c\u044b.<\/p>\n<p>  <\/p>\n<h3>\u041f\u043e\u0438\u0441\u043a \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430<\/h3>\n<p>  <\/p>\n<p>\u0420\u0430\u0431\u043e\u0442\u0430 \u0441 \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0435\u0439 \u043e\u0431\u044b\u0447\u043d\u043e \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0441\u044f \u0441 \u043f\u043e\u0438\u0441\u043a\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 crypt32.dll \u0438\u043c\u0435\u0435\u0442\u0441\u044f \u0434\u0432\u0430 \u043c\u0435\u0442\u043e\u0434\u0430 CertOpenStore (\u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432) \u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 CertOpenSystemStore (\u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u043b\u0438\u0447\u043d\u044b\u0435 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u044b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f). \u0412 \u0441\u0438\u043b\u0443 \u0442\u043e\u0433\u043e, \u0447\u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430\u043c\u0438 \u043d\u0435 \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430\u043c\u0438 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043f\u0435\u0440\u0432\u044b\u0439:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u0438\u0441\u043a \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">\/**&lt;summary&gt;\u041f\u043e\u0438\u0441\u043a \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 (\u043f\u0435\u0440\u0432\u043e\u0433\u043e \u0443\u0434\u043e\u0432\u043b\u0435\u0442\u0432\u043e\u0440\u044f\u044e\u0449\u0435\u0433\u043e \u043a\u0440\u0438\u0442\u0435\u0440\u0438\u044f\u043c \u043f\u043e\u0438\u0441\u043a\u0430)&lt;\/summary&gt; * &lt;param name=&quot;_pFindType&quot;&gt;\u0422\u0438\u043f \u043f\u043e\u0438\u0441\u043a\u0430&lt;\/param&gt; * &lt;param name=&quot;_pFindValue&quot;&gt;\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0438\u0441\u043a\u0430&lt;\/param&gt; * &lt;param name=&quot;_pLocation&quot;&gt;\u041c\u0435\u0441\u0442\u043e &lt;\/param&gt; * &lt;param name=&quot;_pName&quot;&gt;\u0418\u043c\u044f \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430&lt;\/param&gt; * &lt;param name=&quot;_pCert&quot;&gt;\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442&lt;\/param&gt; * &lt;param name=&quot;_sError&quot;&gt;\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439&lt;\/param&gt; * &lt;param name=&quot;_fVerify&quot;&gt;\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0441\u0435\u0440\u0442\u0444\u0438\u0438\u043a\u0430\u0442&lt;\/param&gt; * &lt;returns&gt;\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u044b\u0439 \u043a\u043e\u0434 \u043e\u0448\u0438\u0431\u043a\u0438, \u0435\u0441\u043b\u0438 UConsts.S_OK \u0442\u043e \u0432\u0441\u0435 \u043e\u043a&lt;\/returns&gt; * **\/ public static int FindCertificateCP(string _pFindValue, out X509Certificate2 _pCert, ref string _sError,                                      StoreLocation _pLocation = StoreLocation.CurrentUser,                               StoreName _pName = StoreName.My,                                      X509FindType _pFindType = X509FindType.FindByThumbprint,                                                                                  bool _fVerify = false) {     _pCert = null;     IntPtr   hCert = IntPtr.Zero;                             GCHandle hInternal    = new GCHandle();     GCHandle hFull        = new GCHandle();     IntPtr   hSysStore    = IntPtr.Zero;     try {           \/\/ 0) \u041e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435           hSysStore = UCryptoAPI.CertOpenStore(UCConsts.AR_CERT_STORE_PROV_SYSTEM[fIsLinux.ToByte()],                                                UCConsts.PKCS_7_OR_X509_ASN_ENCODING,                                                IntPtr.Zero,                                                UCUtils.MapX509StoreFlags(_pLocation, OpenFlags.ReadOnly),                                                UCConsts.AR_CRYPTO_STORE_NAME[(int)_pName]);           if (hSysStore == IntPtr.Zero) {               _sError = UCConsts.S_ERR_STORE_OPEN.Frm(Marshal.GetLastWin32Error());               return UConsts.E_CRYPTO_ERR;           }            \/\/ 1) \u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043f\u0430\u043a\u0435\u0442\u0435           if ((_pFindType == X509FindType.FindByThumbprint) || (_pFindType == X509FindType.FindBySerialNumber))           {               byte[] arData = _pFindValue.FromHex();               CRYPTOAPI_BLOB cryptBlob;               cryptBlob.cbData = arData.Length;               hInternal = GCHandle.Alloc(arData, GCHandleType.Pinned);               cryptBlob.pbData = hInternal.AddrOfPinnedObject();               hFull = GCHandle.Alloc(cryptBlob, GCHandleType.Pinned);                               } else {                byte[] arData;                if(fIsLinux)                    arData = Encoding.UTF8.GetBytes(_pFindValue);                else                    arData = Encoding.Unicode.GetBytes(_pFindValue);                hFull = GCHandle.Alloc(arData, GCHandleType.Pinned);           }           \/\/ 2) \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c            IntPtr hPrev = IntPtr.Zero;           do {                hCert = UCryptoAPI.CertFindCertificateInStore(hSysStore,                                                               UCConsts.PKCS_7_OR_X509_ASN_ENCODING, 0,                                                              UCConsts.AR_CRYPT_FIND_TYPE[(int)_pFindType, fIsLinux.ToByte()],                                                              hFull.AddrOfPinnedObject(), hPrev);                \/\/ 2.1) \u041e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0435\u043c \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0438\u0439                if(hPrev != IntPtr.Zero) UCryptoAPI.CertFreeCertificateContext(hPrev);                \/\/ 2.2) \u041a\u043e\u043d\u0447\u0438\u043b\u0438\u0441\u044c \u0432 \u0441\u043f\u0438\u0441\u043a\u0435                if(hCert == IntPtr.Zero) return UConsts.E_NO_CERTIFICATE;                                    \/\/ 2.3) \u041d\u0430\u0448\u043b\u0438 \u0438 \u0432\u0430\u043b\u0438\u0434\u0435\u043d                X509Certificate2 pCert = new ISDP_X509Cert(hCert);                if (!_fVerify || pCert.ISDPVerify()) {                    hCert =  IntPtr.Zero;                    _pCert = pCert;                    return UConsts.S_OK;                }                 hPrev = hCert;                \/\/ \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u043e\u0447\u0438\u0441\u0442\u0438\u043b\u043e                hCert = IntPtr.Zero;           } while(hCert != IntPtr.Zero);           return UConsts.E_NO_CERTIFICATE;     } catch (Exception E) {            _sError = UCConsts.S_FIND_CERT_GEN_ERR.Frm(E.Message);           return UConsts.E_GEN_EXCEPTION;     } finally {           \/\/ \u041e\u0447\u0438\u0449\u0430\u0435\u043c \u0441\u0441\u044b\u043b\u043a\u0438 \u0438 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435           if(hInternal.IsAllocated) hInternal.Free();           if(hFull.IsAllocated) hFull.Free();           if (hCert != IntPtr.Zero) UCryptoAPI.CertFreeCertificateContext(hCert);           UCryptoAPI.CertCloseStore(hSysStore, 0);                     } } <\/code><\/pre>\n<p>  <\/div>\n<\/div>\n<p>  \u041f\u043e\u0438\u0441\u043a \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u0430\u043f\u043e\u0432:   <\/p>\n<ol>\n<li>\u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430;<\/li>\n<li>\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0438\u0449\u0435\u043c;<\/li>\n<li>\u043f\u043e\u0438\u0441\u043a \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430;<\/li>\n<li>\u0435\u0441\u043b\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f, \u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 (\u043e\u043f\u0438\u0441\u0430\u043d\u0430 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u0440\u0430\u0437\u0434\u0435\u043b\u0435);<\/li>\n<li>\u0437\u0430\u043a\u0440\u044b\u0442\u0438\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0438 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0438\u0437 \u043f\u0443\u043d\u043a\u0442\u0430 2 (\u0442.\u00a0\u043a. \u043f\u043e\u0432\u0441\u044e\u0434\u0443 \u0437\u0434\u0435\u0441\u044c \u0438\u0434\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u043d\u0435\u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u044c\u044e .Net \u0437\u0430 \u043d\u0430\u0441 \u043d\u0438\u0447\u0435\u0433\u043e \u043f\u043e \u043e\u0447\u0438\u0441\u0442\u043a\u0435 \u0434\u0435\u043b\u0430\u0442\u044c \u043d\u0435 \u0431\u0443\u0434\u0435\u0442);<\/li>\n<\/ol>\n<p>  <\/p>\n<p>\u0412 \u0445\u043e\u0434\u0435 \u043f\u043e\u0438\u0441\u043a\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u0435\u0441\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0442\u043e\u043d\u043a\u0438\u0445 \u043c\u043e\u043c\u0435\u043d\u0442\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u041a\u0440\u0438\u043f\u0442\u043e\u041f\u0440\u043e \u0432 Linux \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 ANSI \u0441\u0442\u0440\u043e\u043a\u0430\u043c\u0438, \u0430 \u0432 Windows \u0441 UTF8, \u043f\u043e\u044d\u0442\u043e\u043c\u0443:<\/p>\n<p>  <\/p>\n<ol>\n<li>\u043f\u0440\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043c\u0435\u0442\u043e\u0434\u0430 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u044f \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0432 Linux \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0443 \u043a\u043e\u0434\u0430 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0442\u0438\u043f \u043c\u0430\u0440\u0448\u0430\u043b\u0438\u043d\u0433\u0430 [In, MarshalAs (UnmanagedType.LPStr)];<\/li>\n<li>\u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0443 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e \u0438\u043c\u0435\u043d\u0438 Subject) \u0435\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u0432 \u043d\u0430\u0431\u043e\u0440 \u0431\u0430\u0439\u0442 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c\u0438 \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u043a\u0430\u043c\u0438;<\/li>\n<li>\u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u043a\u043e\u043d\u0441\u0442\u0430\u043d\u0442 \u043a\u0440\u0438\u043f\u0442\u043e\u0432\u0430\u043d\u0438\u044f, \u0443 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0435\u0441\u0442\u044c \u0432\u0430\u0440\u0438\u0430\u0446\u0438\u044f \u043f\u043e \u0442\u0438\u043f\u0443 \u0441\u0442\u0440\u043e\u043a\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, CERT_FIND_SUBJECT_STR_A \u0438 CERT_FIND_SUBJECT_STR_W) \u0432 Windows \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432\u044b\u0431\u0438\u0440\u0430\u0442\u044c *_W, \u0430 \u0432 Linux *_A;<\/li>\n<\/ol>\n<p>  <\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/referencesource.microsoft.com\/#System\/security\/system\/security\/cryptography\/x509\/x509utils.cs,105\">MapX509StoreFlags <\/a>\u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432 Microsoft \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439, \u043e\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0438\u0442\u043e\u0433\u043e\u0432\u0443\u044e \u043c\u0430\u0441\u043a\u0443 \u0438\u0441\u0445\u043e\u0434\u044f \u0438\u0437 .Net \u0444\u043b\u0430\u0433\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0438\u0441\u043a \u0437\u0430\u0432\u0438\u0441\u0438\u0442 \u043e\u0442 \u0442\u0438\u043f\u0430 \u043f\u043e\u0438\u0441\u043a\u0430 (\u0441\u0432\u0435\u0440\u044f\u0439\u0442\u0435\u0441\u044c \u0441 MSDN \u0434\u043b\u044f <a href=\"https:\/\/docs.microsoft.com\/en-us\/windows\/desktop\/api\/wincrypt\/nf-wincrypt-certfindcertificateinstore\">CertFindCertificateInStore<\/a>), \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u043f\u0440\u0438\u0432\u0435\u0434\u0435\u043d\u044b \u0434\u0432\u0430 \u0441\u0430\u043c\u044b\u0445 \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0445 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u2014 \u0434\u043b\u044f \u0441\u0442\u0440\u043e\u043a\u043e\u0432\u043e\u0433\u043e \u0444\u043e\u0440\u043c\u0430\u0442\u0430 (\u0438\u043c\u0435\u043d\u0430 Subject, Issuer \u0438 \u043f\u0440\u043e\u0447) \u0438 \u0431\u0438\u043d\u0430\u0440\u043d\u043e\u0433\u043e (\u043e\u0442\u043f\u0435\u0447\u0430\u0442\u043e\u043a, \u0441\u0435\u0440\u0438\u0439\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440).<\/p>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 \u0438\u0437 IntPtr \u0432 Windows \u0438 \u0432 Linux \u0441\u0438\u043b\u044c\u043d\u043e \u043e\u0442\u043b\u0438\u0447\u0430\u0435\u0442\u0441\u044f. Windows \u0441\u043e\u0437\u0434\u0430\u0441\u0442 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c:  <\/p>\n<pre><code class=\"cs\"> new X509Certificate2(hCert);<\/code><\/pre>\n<\/p>\n<p>  <\/p>\n<p>\u0432 Linux \u0436\u0435 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u0432\u0430\u0442\u044c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 \u0432 \u0434\u0432\u0430 \u044d\u0442\u0430\u043f\u0430:  <\/p>\n<pre><code class=\"cs\">X509Certificate2(new X509Certificate(hCert));<\/code><\/pre>\n<\/p>\n<p>  <\/p>\n<p>\u0412 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c \u043d\u0430\u043c \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u043e\u0441\u0442\u0443\u043f \u043a hCert, \u0438 \u0435\u0433\u043e \u043d\u0430\u0434\u043e \u0431\u044b \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u043e\u0431\u044a\u0435\u043a\u0442\u0435 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430. \u0412 Windows \u0435\u0433\u043e \u043f\u043e\u0437\u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u044c \u0438\u0437 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 Handle, \u043e\u0434\u043d\u0430\u043a\u043e Linux \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u0442 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 CERT_CONTEXT, \u043b\u0435\u0436\u0430\u0449\u0443\u044e \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435 hCert, \u0432 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 x509_st (OpenSSL) \u0438 \u0438\u043c\u0435\u043d\u043d\u043e \u0435\u0435 \u043f\u0440\u043e\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0432 Handle. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0442\u043e\u0438\u0442 \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0430 \u043e\u0442 X509Certificate2 (ISDP_X509Cert \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435), \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442 \u0443 \u0441\u0435\u0431\u044f \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u043b\u0435 hCert \u0432 \u043e\u0431\u0435\u0438\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445.<\/p>\n<p>  <\/p>\n<p>\u041d\u0435 \u0441\u0442\u043e\u0438\u0442 \u0437\u0430\u0431\u044b\u0432\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u043d\u0435\u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u0435\u0435 \u043d\u0430\u0434\u043e \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0442\u044c \u043f\u043e\u0441\u043b\u0435 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b. \u0422.\u043a. \u0432 .Net 4.5 X509Certificate2 \u043d\u0435 Disposable \u2014 \u043e\u0447\u0438\u0441\u0442\u043a\u0443 \u043c\u0435\u0442\u043e\u0434\u043e\u043c CertFreeCertificateContext, \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u0432\u043e\u0434\u0438\u0442\u044c \u0432 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435.<\/p>\n<p>  <\/p>\n<h3>\u0424\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u0438<\/h3>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u0440\u0430\u0431\u043e\u0442\u0435 \u0441 \u0413\u041e\u0421\u0422\u043e\u0432\u044b\u043c\u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430\u043c\u0438 \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435\u0433\u0434\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u043e\u0442\u0446\u0435\u043f\u043b\u0435\u043d\u043d\u044b\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u0438 \u0441 \u043e\u0434\u043d\u0438\u043c \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u043e\u043c. \u0414\u043b\u044f \u0442\u043e\u0433\u043e \u0447\u0442\u043e\u0431\u044b \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0442\u0430\u043a\u0443\u044e \u043f\u043e\u0434\u043f\u0438\u0441\u044c \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u0431\u043b\u043e\u043a \u043a\u043e\u0434\u0430:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0424\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u0438<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">\/**&lt;summary&gt; \u041f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e&lt;\/summary&gt; * &lt;param name=&quot;_arData&quot;&gt;\u0414\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0438\u044f&lt;\/param&gt; * &lt;param name=&quot;_pCert&quot;&gt;\u0421\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442&lt;\/param&gt; * &lt;param name=&quot;_sError&quot;&gt;\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439&lt;\/param&gt; * &lt;param name=&quot;_arRes&quot;&gt;\u041f\u043e\u0434\u043f\u0438\u0441\u044c \u0441\u0435\u0440\u0442\u0444\u0438\u0438\u043a\u0430\u0442\u0430&lt;\/param&gt; * &lt;returns&gt;\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u044b\u0439 \u043a\u043e\u0434 \u043e\u0448\u0438\u0431\u043a\u0438, \u0435\u0441\u043b\u0438 UConsts.S_OK \u0442\u043e \u0432\u0441\u0435 \u043e\u043a&lt;\/returns&gt; * **\/ public static int SignDataCP(byte[] _arData, X509Certificate2 _pCert, out byte[] _arRes, ref string _sError) {     _arRes = new byte[0];     \/\/ 0) \u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b     CRYPT_SIGN_MESSAGE_PARA pParams = new CRYPT_SIGN_MESSAGE_PARA();     pParams.cbSize = Marshal.SizeOf(typeof(CRYPT_SIGN_MESSAGE_PARA));     pParams.dwMsgEncodingType      = (int)(UCConsts.PKCS_7_OR_X509_ASN_ENCODING);     pParams.pSigningCert           = _pCert.getRealHandle();     pParams.cMsgCert               = 1;                 pParams.HashAlgorithm.pszObjId = _pCert.getHashAlgirtmOid();     IntPtr pGlobData = Marshal.AllocHGlobal(_arData.Length);     GCHandle pGC = GCHandle.Alloc(_pCert.getRealHandle(), GCHandleType.Pinned);     try {         pParams.rgpMsgCert = pGC.AddrOfPinnedObject();         Marshal.Copy(_arData, 0, pGlobData, _arData.Length);         uint iLen = 50000;         byte[] arRes = new byte[iLen];         \/\/ 1) \u0424\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u0438         if (!UCryptoAPI.CryptSignMessage(ref pParams, true, 1, new IntPtr[1] { pGlobData },                                          new uint[1] { (uint)_arData.Length }, arRes, ref iLen)) {             _sError = UCConsts.S_MAKE_SIGN_ERR.Frm(Marshal.GetLastWin32Error());             return UConsts.E_CRYPTO_ERR;         }         Array.Resize(ref arRes, (int)iLen);         _arRes = arRes;         return UConsts.S_OK;;     } catch (Exception E) {          _sError = UCConsts.S_MAKE_SIGN_ERR.Frm(E.Message);         return UConsts.E_GEN_EXCEPTION;     } finally {         pGC.Free();         Marshal.FreeHGlobal(pGlobData);     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0412 \u0445\u043e\u0434\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u043c\u0435\u0442\u043e\u0434\u0430 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0438 \u0432\u044b\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0438\u044f. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0442\u044c \u0441\u043e\u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432 \u043f\u043e\u0434\u043f\u0438\u0441\u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u044b \u0434\u043b\u044f \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u043b\u043d\u043e\u0439 \u0446\u0435\u043f\u043e\u0447\u043a\u0438 (\u043f\u043e\u043b\u044f cMsgCert \u0438 rgpMsgCert, \u043f\u0435\u0440\u0432\u044b\u0439 \u0445\u0440\u0430\u043d\u0438\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432, \u0432\u0442\u043e\u0440\u043e\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0441\u044b\u043b\u043e\u043a \u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u044d\u0442\u0438\u0445 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432).<\/p>\n<p>  <\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0434\u043b\u044f \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e\u0433\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043e\u0434\u043d\u043e\u0439 \u043f\u043e\u0434\u043f\u0438\u0441\u044c\u044e. \u042d\u0442\u043e, \u043a\u0441\u0442\u0430\u0442\u0438, \u043d\u0435 \u043f\u0440\u043e\u0442\u0438\u0432\u043e\u0440\u0435\u0447\u0438\u0442 63 \u0424\u0417 \u0438 \u0431\u044b\u0432\u0430\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u0443\u0434\u043e\u0431\u043d\u043e, \u0442.\u00a0\u043a. \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0432\u0440\u044f\u0434 \u043b\u0438 \u043e\u0431\u0440\u0430\u0434\u0443\u0435\u0442\u0441\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0440\u0430\u0437 \u043d\u0430\u0436\u0438\u043c\u0430\u0442\u044c \u043d\u0430 \u043a\u043d\u043e\u043f\u043a\u0443 \u00ab\u043f\u043e\u0434\u043f\u0438\u0441\u0430\u0442\u044c\u00bb.<\/p>\n<p>  <\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u043d\u043e\u0441\u0442\u044c\u044e \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0442\u043e, \u0447\u0442\u043e \u043e\u043d \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 \u0434\u0432\u0443\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432, \u0445\u0430\u0440\u0430\u043a\u0442\u0435\u0440\u043d\u043e\u0433\u043e \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u0447\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0445 \u0441 \u0431\u043e\u043b\u044c\u0448\u0438\u043c\u0438 \u0431\u043b\u043e\u043a\u0430\u043c\u0438 \u043f\u0430\u043c\u044f\u0442\u0438 (\u043f\u0435\u0440\u0432\u044b\u0439 \u0441 null \u2014 \u0432\u044b\u0434\u0430\u0435\u0442 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u0443\u044e \u0434\u043b\u0438\u043d\u0443 \u0431\u0443\u0444\u0435\u0440\u0430, \u0432\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u043f\u043e\u043b\u043d\u044f\u0435\u0442 \u0431\u0443\u0444\u0435\u0440). \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u043e\u0439 \u0431\u0443\u0444\u0435\u0440, \u0430 \u0437\u0430\u0442\u0435\u043c \u0443\u043a\u043e\u0440\u043e\u0442\u0438\u0442\u044c \u0435\u0433\u043e \u043f\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0434\u043b\u0438\u043d\u0435.<\/p>\n<p>  <\/p>\n<p>\u0415\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u043e\u0439 \u0441\u0435\u0440\u044c\u0435\u0437\u043d\u043e\u0439 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u043e\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e\u0438\u0441\u043a OID \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0445\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f (Digest) \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 \u043f\u0440\u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u2014 \u0432 \u044f\u0432\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \u0435\u0433\u043e \u043d\u0435\u0442 \u0432 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0435 (\u0442\u0430\u043c \u0435\u0441\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0441\u0430\u043c\u043e\u0439 \u043f\u043e\u0434\u043f\u0438\u0441\u0438). \u0418 \u0435\u0441\u043b\u0438 \u0432 Windows \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u0443\u0441\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u043e\u0439 \u2014 \u043e\u043d \u043f\u043e\u0434\u0446\u0435\u043f\u0438\u0442\u0441\u044f \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438, \u043d\u043e Linux \u043e\u0442\u043a\u0430\u0436\u0435\u0442\u0441\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0442\u044c \u0435\u0441\u043b\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u043d\u0435 \u0442\u043e\u0442.<\/p>\n<p>  <\/p>\n<p>\u041d\u043e \u0442\u0443\u0442 \u0435\u0441\u0442\u044c \u0445\u0438\u0442\u0440\u043e\u0441\u0442\u044c \u2014 \u0432 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e\u0431 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u0438 (\u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 CRYPT_OID_INFO) \u0432 pszOID \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f OID \u043f\u043e\u0434\u043f\u0438\u0441\u0438, \u0430 \u0432 Algid \u2014 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0445\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0410 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c Algid \u0432 OID \u0443\u0436\u0435 \u0434\u0435\u043b\u043e \u0442\u0435\u0445\u043d\u0438\u043a\u0438:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 OID \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0445\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">\/**&lt;summary&gt;\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 OID \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0445\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0443&lt;\/summary&gt; * &lt;param name=&quot;_hCertHandle&quot;&gt;\u0425\u044d\u043d\u0434\u043b \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430&lt;\/param&gt; * &lt;param name=&quot;_sOID&quot;&gt;\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 OID&lt;\/param&gt; * &lt;param name=&quot;_sError&quot;&gt;\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439&lt;\/param&gt; * &lt;returns&gt;\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043a\u043e\u0434 \u043e\u0448\u0438\u0431\u043a\u0438, \u0435\u0441\u043b\u0438 UConsts.S_OK \u0442\u043e \u0432\u0441\u0435 \u043e\u043a&lt;\/returns&gt; * **\/ internal static int GetHashAlgoritmOID(IntPtr _hCertHandle, out string _sOID, ref string _sError) {     _sOID = &quot;&quot;;     IntPtr hHashAlgInfo = IntPtr.Zero;     IntPtr hData        = IntPtr.Zero;     try {         CERT_CONTEXT pContext = (CERT_CONTEXT)Marshal.PtrToStructure(_hCertHandle, typeof(CERT_CONTEXT));         CERT_INFO pCertInfo = (CERT_INFO)Marshal.PtrToStructure(pContext.pCertInfo, typeof(CERT_INFO));         \/\/ \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c AlgID         \/\/ \u0447\u0435\u0440\u0435\u0437 UCryptoAPI.CertAlgIdToOID  \u0432 Windows \u043f\u0435\u0440\u0432\u044b\u0439 \u0440\u0430\u0437 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442, \u0432\u0442\u043e\u0440\u043e\u0439 \u043f\u0430\u0434\u0430\u0435\u0442         byte[] arData = BitConverter.GetBytes(UCryptoAPI.CertOIDToAlgId(pCertInfo.SignatureAlgorithm.pszObjId));         hData = Marshal.AllocHGlobal(arData.Length);                         Marshal.Copy(arData, 0, hData, arData.Length);         \/\/ \u041f\u043e\u0438\u0441\u043a OID         hHashAlgInfo = UCryptoAPI.CryptFindOIDInfo(UCConsts.CRYPT_OID_INFO_ALGID_KEY,                                                    hData,                                                    UCConsts.CRYPT_HASH_ALG_OID_GROUP_ID);         if (hHashAlgInfo == IntPtr.Zero) {             _sError = UCConsts.S_NO_HASH_ALG_ERR.Frm( Marshal.GetLastWin32Error());             return UConsts.E_GEN_EXCEPTION;         }         CRYPT_OID_INFO pHashAlgInfo = (CRYPT_OID_INFO)Marshal.PtrToStructure(hHashAlgInfo, typeof(CRYPT_OID_INFO));         _sOID = pHashAlgInfo.pszOID;         return UConsts.S_OK;     } catch (Exception E) {         _sError = UCConsts.S_DETERM_HASH_ALG_ERR.Frm(E.Message);         return UConsts.E_GEN_EXCEPTION;     } finally {          Marshal.FreeHGlobal(hData);     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0412\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0432 \u043a\u043e\u0434 \u043c\u043e\u0436\u043d\u043e \u0443\u0434\u0438\u0432\u0438\u0442\u0441\u044f, \u0447\u0442\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0441\u0442\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c (CertOIDToAlgId) \u0430 Oid \u043f\u043e \u043d\u0435\u043c\u0443 \u2014 \u0441\u043b\u043e\u0436\u043d\u044b\u043c (CryptFindOIDInfo). \u041b\u043e\u0433\u0438\u0447\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u0442\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043b\u0438\u0431\u043e \u043e\u0431\u0430 \u0441\u043b\u043e\u0436\u043d\u044b\u0445, \u043b\u0438\u0431\u043e \u043e\u0431\u0430 \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u0441\u043f\u043e\u0441\u043e\u0431\u0430, \u0438 \u0432 Linux \u043e\u0431\u0430 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0443\u0441\u043f\u0435\u0448\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442. \u041e\u0434\u043d\u0430\u043a\u043e \u0432 Windows \u0441\u043b\u043e\u0436\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440\u0430 \u0438 \u043f\u0440\u043e\u0441\u0442\u043e\u0439 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f OID \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043d\u0435\u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u044b\u043c \u0440\u0435\u0448\u0435\u043d\u0438\u0435\u043c \u0431\u0443\u0434\u0435\u0442 \u0432\u043e\u0442 \u0442\u0430\u043a\u043e\u0439 \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u0439 \u0433\u0438\u0431\u0440\u0438\u0434.<\/p>\n<p>  <\/p>\n<h3>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u0438<\/h3>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0434\u0432\u0430 \u044d\u0442\u0430\u043f\u0430, \u0432 \u043d\u0430\u0447\u0430\u043b\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u044c, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043e\u043d\u0430 \u0431\u044b\u043b\u0430 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0430 (\u0446\u0435\u043f\u043e\u0447\u043a\u0430, \u0434\u0430\u0442\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u0438 \u043f\u0440\u043e\u0447).<br \/>  \u0422\u0430\u043a \u0436\u0435 \u043a\u0430\u043a \u0438 \u043f\u0440\u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u043d\u0430\u0431\u043e\u0440 \u043f\u043e\u0434\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445, \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u043e\u0434\u043f\u0438\u0441\u0438 \u0438 \u0441\u0430\u043c\u0443 \u043f\u043e\u0434\u043f\u0438\u0441\u044c:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u0438<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">\/**&lt;summary&gt;\u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u0443\u044e \u0441\u043a\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u0438 &lt;\/summary&gt; * &lt;returns&gt;\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443&lt;\/returns&gt; * **\/ internal static CRYPT_VERIFY_MESSAGE_PARA GetStdSignVerifyPar() {     CRYPT_VERIFY_MESSAGE_PARA  pVerifyParams  =  new CRYPT_VERIFY_MESSAGE_PARA();     pVerifyParams.cbSize = (int)Marshal.SizeOf(pVerifyParams);     pVerifyParams.dwMsgEncodingType = UCConsts.PKCS_7_OR_X509_ASN_ENCODING;     pVerifyParams.hCryptProv = 0;     pVerifyParams.pfnGetSignerCertificate   = IntPtr.Zero;     pVerifyParams.pvGetArg  = IntPtr.Zero;     return pVerifyParams; } \/**&lt;summary&gt;\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043f\u043e\u0434\u043f\u0438\u0441\u044c&lt;\/summary&gt; * &lt;param name=&quot;_arData&quot;&gt;\u0434\u0430\u043d\u043d\u044b\u0435, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0431\u044b\u043b\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u044b&lt;\/param&gt; * &lt;param name=&quot;_pSign&quot;&gt;\u043f\u043e\u0434\u043f\u0438\u0441\u044c&lt;\/param&gt; * &lt;param name=&quot;_pCert&quot;&gt;\u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442&lt;\/param&gt; * &lt;param name=&quot;_sError&quot;&gt;\u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439&lt;\/param&gt; * &lt;param name=&quot;_fVerifyOnlySign&quot;&gt;\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u044c&lt;\/param&gt; * &lt;param name=&quot;_pRevMode&quot;&gt;\u0420\u0435\u0436\u0438\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430&lt;\/param&gt; * &lt;param name=&quot;_pRevFlag&quot;&gt;\u0424\u043b\u0430\u0433 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u0435\u0440\u0442\u0444\u0438\u0438\u043a\u0430\u0442\u0430&lt;\/param&gt; * &lt;returns&gt;\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u044b\u0439 \u043a\u043e\u0434 \u043e\u0448\u0438\u0431\u043a\u0438, \u0435\u0441\u043b\u0438 UConsts.S_OK \u0442\u043e \u0432\u0441\u0435 \u043e\u043a&lt;\/returns&gt; * &lt;remarks&gt;\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442&lt;\/remarks&gt; * **\/ public static int CheckSignCP(byte[] _arData, byte[] _pSign, out X509Certificate2 _pCert, ref string _sError,                               bool _fVerifyOnlySign = true,                                X509RevocationMode _pRevMode = X509RevocationMode.Online,                               X509RevocationFlag _pRevFlag = X509RevocationFlag.ExcludeRoot){     _pCert = null;     IntPtr pHData = Marshal.AllocHGlobal(_arData.Length);     GCHandle pCertContext = GCHandle.Alloc(IntPtr.Zero, GCHandleType.Pinned);     try {         Marshal.Copy(_arData, 0, pHData, _arData.Length);         CRYPT_VERIFY_MESSAGE_PARA pVerParam = UCUtils.GetStdSignVerifyPar();         \/\/ 0) \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u0438         bool fRes = UCryptoAPI.CryptVerifyDetachedMessageSignature(                                            ref pVerParam,                     \/\/ \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u043e\u0434\u0442\u0432\u0435\u0440\u0436\u0434\u0435\u043d\u0438\u044f                                            0,                                 \/\/ \u0418\u043d\u0434\u0435\u043a\u0441 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u0430                                            _pSign,                            \/\/ \u041f\u043e\u0434\u043f\u0438\u0441\u044c                                            _pSign.Length,                     \/\/ \u0414\u043b\u0438\u043d\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u0438                                            1,                                 \/\/ \u043a\u043e\u043b-\u0432\u043e \u0444\u0430\u0439\u043b\u043e\u0432 \u043d\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u044c                                            new IntPtr[1] { pHData },          \/\/ \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u044b                                            new int[1] { _arData.Length },     \/\/ \u0414\u043b\u0438\u043d\u044b \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u0445 \u0444\u0430\u0439\u043b\u043e\u0432                                            pCertContext.AddrOfPinnedObject());\/\/ \u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442         if (!fRes) {             _sError = UCConsts.S_SIGN_CHECK_ERR.Frm(Marshal.GetLastWin32Error().ToString(&quot;X&quot;));             return UConsts.E_CRYPTO_ERR;         }         \/\/ 1) \u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0441\u0435\u0440\u0442\u0444\u0438\u0438\u043a\u0430\u0442\u0430         _pCert = new ISDP_X509Cert((IntPtr)pCertContext.Target);         if (_pCert == null) {             _sError = UCConsts.S_SIGN_CHECK_CERT_ERR;             return UConsts.E_CRYPTO_ERR;         }         \/\/ 2) \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430         if (!_fVerifyOnlySign) {             List&lt;DateTime&gt; pDates;             \/\/ 2.1) \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0434\u0430\u0442             int iRes = GetSignDateTimeCP(_pSign, out pDates, ref  _sError);             \/\/ 2.2) \u0412\u0435\u0440\u0438\u0444\u0438\u0446\u0438\u0440\u0443\u0435\u043c \u043f\u0435\u0440\u0432\u044b\u0439 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442             iRes = _pCert.ISDPVerify(ref _sError, pDates[0], _pRevMode, _pRevFlag);             if (iRes != UConsts.S_OK) return iRes;         }         return UConsts.S_OK;     } catch (Exception E) {         _sError = UCConsts.S_SIGN_CHECK_ERR.Frm(E.Message);         return UConsts.E_GEN_EXCEPTION;;     } finally {         Marshal.FreeHGlobal(pHData);         if ((_pCert == null) && pCertContext.IsAllocated && ((IntPtr)pCertContext.Target != IntPtr.Zero))             UCryptoAPI.CertFreeCertificateContext((IntPtr)pCertContext.Target);         pCertContext.Free();                     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0443\u0434\u043e\u0431\u0441\u0442\u0432\u0430 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0441 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u043c\u0438 \u0432\u044b\u043d\u0435\u0441\u0435\u043d \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 (GetStdSignVerifyPar). \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f \u0441\u0430\u043c\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u044c \u0438 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0432\u044b\u0439 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442 (\u043f\u043e \u0445\u043e\u0440\u043e\u0448\u0435\u043c\u0443 \u043d\u0430\u0434\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0432\u0441\u0435\u0445, \u043d\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0430\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u043e\u0432 \u044d\u0442\u043e \u0432\u0441\u0435 \u0442\u0430\u043a\u0438 \u044d\u043a\u0437\u043e\u0442\u0438\u043a\u0430).<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u0430 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u0435\u0433\u043e \u0432 \u043d\u0430\u0448 \u043a\u043b\u0430\u0441\u0441 \u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c (\u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u0443\u043a\u0430\u0437\u0430\u043d\u043e \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430\u0445 \u043c\u0435\u0442\u043e\u0434\u0430). \u0414\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f \u0434\u0430\u0442\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u043f\u0435\u0440\u0432\u043e\u0433\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u0430 (\u0441\u043c. \u0440\u0430\u0437\u0434\u0435\u043b \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0438\u0437 \u043f\u043e\u0434\u043f\u0438\u0441\u0438, \u0438 \u0440\u0430\u0437\u0434\u0435\u043b \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430).<\/p>\n<p>  <\/p>\n<h2>\u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0438\u0437 \u043f\u043e\u0434\u043f\u0438\u0441\u0438<\/h2>\n<p>  <\/p>\n<p>\u0427\u0430\u0441\u0442\u043e \u0432 \u0441\u0438\u0441\u0442\u0435\u043c\u0430\u0445 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0449\u0438\u0445 \u0441 \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0435\u0439 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u0435\u0447\u0430\u0442\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u0438. \u0412 \u043a\u0430\u0436\u0434\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043e\u043d\u043e \u0440\u0430\u0437\u043d\u043e\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043b\u0443\u0447\u0448\u0435 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0438, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0432 \u0443\u0434\u043e\u0431\u043d\u043e\u043c \u0434\u043b\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u0438\u0434\u0435 \u0438 \u0443\u0436\u0435 \u0441 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0442\u044c \u043f\u0435\u0447\u0430\u0442\u043d\u043e\u0435 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u0435. \u0412 .Net \u0442\u0430\u043a\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 \u0435\u0441\u0442\u044c \u2014 SignedCms, \u043e\u0434\u043d\u0430\u043a\u043e \u0435\u0433\u043e \u0430\u043d\u0430\u043b\u043e\u0433 \u0432 mono c \u043f\u043e\u0434\u043f\u0438\u0441\u044f\u043c\u0438 \u041a\u0440\u0438\u0442\u043e\u041f\u0440\u043e, \u0432\u043e \u043f\u0435\u0440\u0432\u044b\u0445 \u043e\u0442\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c, \u0432\u043e \u0432\u0442\u043e\u0440\u044b\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u043c\u043e\u0434\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0440 sealed \u0438 \u0432 \u0442\u0440\u0435\u0442\u044c\u0438\u0445 \u043f\u043e\u0447\u0442\u0438 \u0432\u0441\u0435 \u0441\u0432\u043e\u0439\u0441\u0442\u0432\u0430 \u0443 \u043d\u0435\u0433\u043e \u0437\u0430\u043a\u0440\u044b\u0442\u044b \u043d\u0430 \u0437\u0430\u043f\u0438\u0441\u044c, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0430\u043d\u0430\u043b\u043e\u0433. <\/p>\n<p>  <\/p>\n<p>\u0421\u0430\u043c\u0430 \u043f\u043e \u0441\u0435\u0431\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0434\u0432\u0430 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u0430 \u2014 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u043e\u0432. \u0421\u043f\u0438\u0441\u043e\u043a \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0443\u0441\u0442\u043e\u0439, \u0430 \u043c\u043e\u0436\u0435\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0442\u044c \u0432 \u0441\u0435\u0431\u0435 \u0432\u0441\u0435 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u044b \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438, \u0432\u043a\u043b\u044e\u0447\u0430\u044f \u043f\u043e\u043b\u043d\u044b\u0435 \u0446\u0435\u043f\u043e\u0447\u043a\u0438. \u0421\u043f\u0438\u0441\u043e\u043a \u0436\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u043e\u0432 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u043a\u043e\u043b-\u0432\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0445 \u043f\u043e\u0434\u043f\u0438\u0441\u0435\u0439. \u0421\u0432\u044f\u0437\u044c \u043c\u0435\u0436\u0434\u0443 \u043d\u0438\u043c\u0438 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u043e \u0441\u0435\u0440\u0438\u0439\u043d\u043e\u043c\u0443 \u043d\u043e\u043c\u0435\u0440\u0443 \u0438 \u0438\u0437\u0434\u0430\u0442\u0435\u043b\u044e (Issuer). \u0422\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u0432 \u043e\u0434\u043d\u043e\u0439 \u043f\u043e\u0434\u043f\u0438\u0441\u0438 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0434\u0432\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 \u043e\u0442 \u0440\u0430\u0437\u043d\u044b\u0445 \u0438\u0437\u0434\u0430\u0442\u0435\u043b\u0435\u0439 \u0441 \u043e\u0434\u043d\u0438\u043c \u0441\u0435\u0440\u0438\u0439\u043d\u044b\u043c \u043d\u043e\u043c\u0435\u0440\u043e\u043c, \u043d\u043e \u043d\u0430 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u0435 \u044d\u0442\u0438\u043c \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u043d\u0435\u0431\u0440\u0435\u0447\u044c \u0438 \u0438\u0441\u043a\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e \u0441\u0435\u0440\u0438\u0439\u043d\u043e\u043c\u0443 \u043d\u043e\u043c\u0435\u0440\u0443.<\/p>\n<p>  <\/p>\n<p>\u0427\u0442\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u0438\u0437 \u043f\u043e\u0434\u043f\u0438\u0441\u0438<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">\/**&lt;summary&gt;\u0420\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c&lt;\/summary&gt; * &lt;param name=&quot;_arSign&quot;&gt;\u041f\u043e\u0434\u043f\u0438\u0441\u044c&lt;\/param&gt; * &lt;param name=&quot;_sError&quot;&gt;\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439&lt;\/param&gt; * &lt;returns&gt;\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043a\u043e\u0434 \u043e\u0448\u0438\u0431\u043a\u0438, \u0435\u0441\u043b\u0438 UConsts.S_OK \u0442\u043e \u0432\u0441\u0435 \u043e\u043a&lt;\/returns&gt; * **\/ public int Decode(byte[] _arSign, ref string _sError) {     IntPtr hMsg = IntPtr.Zero;     \/\/ 0) \u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e      try {         hMsg = UCryptoAPI.CryptMsgOpenToDecode(UCConsts.PKCS_7_OR_X509_ASN_ENCODING, UCConsts.CMSG_DETACHED_FLAG,                                                0, IntPtr.Zero, IntPtr.Zero, IntPtr.Zero);         if (hMsg == IntPtr.Zero) {             _sError = UCConsts.S_CRYP_MSG_FORM_ERR.Frm(Marshal.GetLastWin32Error());             return UConsts.E_CRYPTO_ERR;         }         \/\/ 1) \u0412\u043d\u043e\u0441\u0438\u043c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435         if (!UCryptoAPI.CryptMsgUpdate(hMsg, _arSign, (uint)_arSign.Length, true)) {             _sError = UCConsts.S_CRYP_MSG_SIGN_COPY_ERR.Frm(Marshal.GetLastWin32Error());             return UConsts.E_CRYPTO_ERR;         }         \/\/ 2) \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0442\u0438\u043f (PKCS7 SignedData)         uint iMessType = UCUtils.GetCryptMsgParam&lt;uint&gt;(hMsg, UCConsts.CMSG_TYPE_PARAM);         if (UCConsts.CMSG_SIGNED != iMessType) {             _sError = UCConsts.S_CRYP_MSG_SIGN_TYPE_ERR.Frm(iMessType, UCConsts.CMSG_SIGNED);             return UConsts.E_CRYPTO_ERR;         }         \/\/ 3) \u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0435\u0440\u0442\u0444\u0438\u043a\u0430\u0442\u043e\u0432         fpCertificates = UCUtils.GetSignCertificates(hMsg);         \/\/ 4) \u0421\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u043e\u0432                     uint iSignerCount =  UCUtils.GetCryptMsgParam&lt;uint&gt;(hMsg, UCConsts.CMSG_SIGNER_COUNT_PARAM);         for (int i = 0; i &lt; iSignerCount; i++) {              ISDPSignerInfo pInfo = new ISDPSignerInfo();              fpSignerInfos.Add(pInfo);              int iRes = pInfo.Decode(hMsg, i, this, ref _sError);              if (iRes != UConsts.S_OK) return iRes;         }         return UConsts.S_OK;     } catch (Exception E) {         _sError = UCConsts.S_SIGN_INFO_GEN_ERR.Frm(E.Message);         return UConsts.E_GEN_EXCEPTION;     } finally {         if(hMsg != IntPtr.Zero) UCryptoAPI.CryptMsgClose(hMsg);     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0420\u0430\u0437\u0431\u043e\u0440 \u043f\u043e\u0434\u043f\u0438\u0441\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044d\u0442\u0430\u043f\u043e\u0432, \u0432\u043d\u0430\u0447\u0430\u043b\u0435 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f (CryptMsgOpenToDecode), \u0437\u0430\u0442\u0435\u043c \u0432 \u043d\u0435\u0435 \u0432\u043d\u043e\u0441\u044f\u0442\u0441\u044f \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u0438 (CryptMsgUpdate). \u041e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0447\u0442\u043e \u044d\u0442\u043e \u0440\u0435\u0430\u043b\u044c\u043d\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u044c \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432, \u0430 \u043f\u043e\u0442\u043e\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u043e\u0432. \u0421\u043f\u0438\u0441\u043e\u043a \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e :<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u043f\u0438\u0441\u043a\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">\/**&lt;summary&gt;\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044e \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u043f\u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0438 &lt;\/summary&gt; * &lt;param name=&quot;_hMsg&quot;&gt;Handle \u043f\u043e\u0434\u043f\u0438\u0441\u0438&lt;\/param&gt; * &lt;returns&gt;\u041a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432&lt;\/returns&gt; * **\/ internal static X509Certificate2Collection GetSignCertificates(IntPtr _hMsg) {     X509Certificate2Collection certificates = new X509Certificate2Collection();     uint iCnt = GetCryptMsgParam&lt;uint&gt;(_hMsg, UCConsts.CMSG_CERT_COUNT_PARAM);     for (int i = 0; i &lt; iCnt; i++) {         IntPtr hInfo = IntPtr.Zero;         IntPtr hCert = IntPtr.Zero;         try {             uint iLen = 0;             if (!GetCryptMsgParam(_hMsg, UCConsts.CMSG_CERT_PARAM, out hInfo, out iLen)) continue;             hCert = UCryptoAPI.CertCreateCertificateContext(UCConsts.PKCS_7_OR_X509_ASN_ENCODING, hInfo, iLen);             if (hCert != IntPtr.Zero) {                 certificates.Add(new ISDP_X509Cert(hCert));                 hCert = IntPtr.Zero;             }         } finally {             if (hInfo != IntPtr.Zero) Marshal.FreeHGlobal(hInfo);             if (hInfo != IntPtr.Zero) Marshal.FreeHGlobal(hCert);         }     }     return certificates; } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0442\u0441\u044f \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u0438\u0437 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u0430 CMSG_CERT_COUNT_PARAM, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043e\u0432\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043a\u0430\u0436\u0434\u043e\u043c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0435. \u0417\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 \u0438 \u043d\u0430 \u0435\u0433\u043e \u043e\u0441\u043d\u043e\u0432\u0435 \u0441\u0430\u043c\u043e\u0433\u043e \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430.<\/p>\n<p>  <\/p>\n<p>\u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u0430 \u0441\u043b\u043e\u0436\u043d\u0435\u0435. \u0412 \u043d\u0438\u0445 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0443\u043a\u0430\u0437\u0430\u043d\u0438\u0435 \u043d\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 \u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u043e\u0434\u043f\u0438\u0441\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0434\u0430\u0442\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0438\u044f). \u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043e\u0431\u0440\u0430\u0437\u043e\u043c:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">\/**&lt;summary&gt;\u0420\u0430\u0441\u043f\u0430\u0440\u0441\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0438\u0437 \u043f\u043e\u0434\u043f\u0438\u0441\u0438&lt;\/summary&gt; * &lt;param name=&quot;_hMsg&quot;&gt;Handler \u043f\u043e\u0434\u043f\u0438\u0441\u0438&lt;\/param&gt; * &lt;param name=&quot;_iIndex&quot;&gt;\u0418\u043d\u0434\u0435\u043a\u0441 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u0430&lt;\/param&gt; * &lt;param name=&quot;_pSignedCms&quot;&gt;\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u0438&lt;\/param&gt; * &lt;param name=&quot;_sError&quot;&gt;\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439&lt;\/param&gt; * &lt;returns&gt;\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043a\u043e\u0434 \u043e\u0448\u0438\u0431\u043a\u0438, \u0435\u0441\u043b\u0438 UConsts.S_OK \u0442\u043e \u0432\u0441\u0435 \u043e\u043a&lt;\/returns&gt; * **\/ public int Decode(IntPtr _hMsg, int _iIndex, ISDPSignedCms _pSignedCms, ref string _sError) {     \/\/ 1) \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0434\u043b\u0438\u043d\u0443     uint iLen = 0;     \/\/ 2) \u0421\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c     IntPtr hInfo =  IntPtr.Zero;     try {         if (!UCryptoAPI.CryptMsgGetParam(_hMsg, UCConsts.CMSG_SIGNER_INFO_PARAM, (uint)_iIndex, IntPtr.Zero, ref iLen)) {             _sError = UCConsts.S_ERR_SIGNER_INFO_LEN.Frm(_iIndex, Marshal.GetLastWin32Error());             return UConsts.E_CRYPTO_ERR;         }         hInfo = Marshal.AllocHGlobal((int)iLen);         if (!UCryptoAPI.CryptMsgGetParam(_hMsg, UCConsts.CMSG_SIGNER_INFO_PARAM, (uint)_iIndex, hInfo, ref iLen)) {             _sError = UCConsts.S_ERR_SIGNER_INFO.Frm(_iIndex, Marshal.GetLastWin32Error());             return UConsts.E_CRYPTO_ERR;         }         CMSG_SIGNER_INFO pSignerInfo = (CMSG_SIGNER_INFO) Marshal.PtrToStructure(hInfo, typeof(CMSG_SIGNER_INFO));         \/\/ 2.1) \u0418\u0449\u0435\u043c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442         byte[] arSerial = new byte[pSignerInfo.SerialNumber.cbData];         Marshal.Copy(pSignerInfo.SerialNumber.pbData, arSerial, 0, arSerial.Length);         X509Certificate2Collection pLocCerts = _pSignedCms.pCertificates.Find(X509FindType.FindBySerialNumber,                                                                               arSerial.Reverse().ToArray().ToHex(), false);         if (pLocCerts.Count != 1) {             _sError = UCConsts.S_ERR_SIGNER_INFO_CERT.Frm(_iIndex);             return UConsts.E_NO_CERTIFICATE;         }         fpCertificate = pLocCerts[0];         fpSignedAttributes = UCUtils.ReadCryptoAttrsCollection(pSignerInfo.AuthAttrs);         return UConsts.S_OK;     } catch (Exception E) {         _sError = UCConsts.S_ERR_SIGNER_INFO_READ.Frm(_iIndex, E.Message);          return UConsts.E_GEN_EXCEPTION;                 } finally {          if(hInfo != IntPtr.Zero) Marshal.FreeHGlobal(hInfo);     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0412 \u0445\u043e\u0434\u0435 \u043d\u0435\u0433\u043e \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0437\u043c\u0435\u0440 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u0430, \u0430 \u0437\u0430\u0442\u0435\u043c \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442\u0441\u044f \u0438 \u0441\u0430\u043c\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 CMSG_SIGNER_INFO. \u0412 \u043d\u0435\u0439 \u043b\u0435\u0433\u043a\u043e \u043d\u0430\u0439\u0442\u0438 \u0441\u0435\u0440\u0438\u0439\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 \u0438 \u043f\u043e \u043d\u0435\u043c\u0443 \u043d\u0430\u0439\u0442\u0438 \u043d\u0443\u0436\u043d\u044b\u0439 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 \u0432 \u0440\u0430\u043d\u0435\u0435 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u043d\u043e\u043c \u0441\u043f\u0438\u0441\u043a\u0435. \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435, \u0447\u0442\u043e \u0441\u0435\u0440\u0438\u0439\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442\u0441\u044f \u0432 \u043e\u0431\u0440\u0430\u0442\u043d\u043e\u043c \u043f\u043e\u0440\u044f\u0434\u043a\u0435.<\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0441\u043b\u0435 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u043e\u0434\u043f\u0438\u0441\u0438, \u0441\u0430\u043c\u0430\u044f \u0432\u0430\u0436\u043d\u0430\u044f \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u2014 \u0434\u0430\u0442\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0438\u044f (\u0434\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u044d\u0442\u043e \u043d\u0435 \u0432\u0435\u0440\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u0430\u044f \u0441\u0435\u0440\u0432\u0435\u0440\u043e\u043c \u0448\u0442\u0430\u043c\u043f\u0430 \u0434\u0430\u0442\u044b \u0432\u0440\u0435\u043c\u0435\u043d\u0438, \u0434\u043b\u044f \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u044f \u043e\u043d\u0430 \u043e\u0447\u0435\u043d\u044c \u0432\u0430\u0436\u043d\u0430).<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0421\u043f\u0438\u0441\u043e\u043a \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u043f\u043e\u0434\u043f\u0438\u0441\u0438<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">\/**&lt;summary&gt;\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u043f\u043e\u0434\u043f\u0438\u0441\u0438&lt;\/summary&gt; * &lt;param name=&quot;_pAttrs&quot;&gt;\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432&lt;\/param&gt; * &lt;returns&gt;\u041a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f \u0430\u0442\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432&lt;\/returns&gt; * **\/ internal static CryptographicAttributeObjectCollection ReadCryptoAttrsCollection(CRYPT_ATTRIBUTES _pAttrs) {     CryptographicAttributeObjectCollection pRes = new CryptographicAttributeObjectCollection();                 for (int i = 0; i &lt; _pAttrs.cAttr; i++) {         IntPtr hAttr = new IntPtr((long)_pAttrs.rgAttr + (i * Marshal.SizeOf(typeof(CRYPT_ATTRIBUTE))));         CRYPT_ATTRIBUTE pAttr = (CRYPT_ATTRIBUTE) Marshal.PtrToStructure(hAttr, typeof(CRYPT_ATTRIBUTE));         CryptographicAttributeObject pAttrInfo =  new CryptographicAttributeObject(new Oid(pAttr.pszObjId),                                                                                     GetAsnEncodedDataCollection(pAttr));         pRes.Add(pAttrInfo);     }     return pRes; } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0410\u0442\u0440\u0438\u0431\u0443\u0442\u044b \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u044e\u0442 \u0438\u0437 \u0441\u0435\u0431\u044f \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u0441\u043f\u0440\u0430\u0432\u043e\u0447\u043d\u0438\u043a \u0432\u0438\u0434\u0430 Oid \u2013 \u0441\u043f\u0438\u0441\u043e\u043a \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 (\u043f\u043e \u0441\u0443\u0442\u0438 \u044d\u0442\u043e \u0440\u0430\u0437\u043e\u0431\u0440\u0430\u043d\u043d\u0430\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 ASN.1). \u041f\u0440\u043e\u0439\u0434\u044f \u043f\u043e \u043f\u0435\u0440\u0432\u043e\u043c\u0443 \u0443\u0440\u043e\u0432\u043d\u044e \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0432\u043b\u043e\u0436\u0435\u043d\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0430\u0437\u043e\u0431\u0440\u0430\u0442\u044c \u0430\u0442\u0440\u0438\u0431\u0443\u0442 \u043f\u043e\u0434\u043f\u0438\u0441\u0438<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">\/**&lt;summary&gt;\u0421\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043e\u0431\u044a\u0435\u043a\u0442 \u043a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u0438 \u043d\u0443\u0436\u043d\u043e\u0433\u043e \u043a\u043b\u0430\u0441\u0441\u0430 \u043f\u043e \u0438\u043c\u0435\u043d\u0438&lt;\/summary&gt; * &lt;param name=&quot;_sName&quot;&gt;\u0418\u043c\u044f&lt;\/param&gt; * &lt;returns&gt;\u0421\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043e\u0431\u044a\u0435\u043a\u0442&lt;\/returns&gt; * **\/ internal static Pkcs9AttributeObject Pkcs9AttributeFromOID(string _sName) {     switch (_sName) {         case UCConsts.S_SIGN_DATE_OID    : return new Pkcs9SigningTime();            \/\/        case UConsts.S_CONTENT_TYPE_OID : return new Pkcs9ContentType();      -&gt;&gt; \u0432 Mono \u043f\u0430\u0434\u0430\u0435\u0442                           \/\/        case UConsts.S_MESS_DIGEST_OID  : return new Pkcs9MessageDigest();         default:  return new Pkcs9AttributeObject();     }         }  \/**&lt;summary&gt;\u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u043a\u043e\u043b\u043b\u0435\u043a\u0443\u0446\u0438\u044e ASN&lt;\/summary&gt; * &lt;param name=&quot;_pAttr&quot;&gt;\u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430&lt;\/param&gt; * &lt;returns&gt;\u041a\u043e\u043b\u043b\u0435\u043a\u0446\u0438\u044f&lt;\/returns&gt; * **\/ internal static AsnEncodedDataCollection GetAsnEncodedDataCollection (CRYPT_ATTRIBUTE _pAttr) {     AsnEncodedDataCollection pRes = new AsnEncodedDataCollection();     Oid pOid = new Oid(_pAttr.pszObjId);     string sOid = pOid.Value;     for (uint i = 0; i &lt; _pAttr.cValue; i++) {         checked {             IntPtr pAttributeBlob = new IntPtr((long)_pAttr.rgValue + (i * Marshal.SizeOf(typeof(CRYPTOAPI_BLOB))));             Pkcs9AttributeObject attribute = new Pkcs9AttributeObject(pOid, BlobToByteArray(pAttributeBlob));             Pkcs9AttributeObject customAttribute = Pkcs9AttributeFromOID(sOid);             if (customAttribute != null) {                 customAttribute.CopyFrom(attribute);                 attribute = customAttribute;             }             pRes.Add(attribute);         }     }     return pRes; } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041a\u043b\u044e\u0447\u0435\u0432\u043e\u0439 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u044b\u0439 \u043f\u043e\u0434\u0431\u043e\u0440 \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a\u0430 Pkcs9AttributeObject. \u041f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0432 mono \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0438 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432\u044b\u0431\u043e\u0440 \u043a\u043b\u0430\u0441\u0441\u0430 \u043f\u0440\u044f\u043c\u043e \u0432 \u043a\u043e\u0434\u0435. \u041a \u0442\u043e\u043c\u0443 \u0436\u0435 \u0438\u0437 \u043e\u0441\u043d\u043e\u0432\u043d\u044b\u0445 \u0442\u0438\u043f\u043e\u0432 Mono \u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u0430\u0442\u0443.<\/p>\n<p>  <\/p>\n<p>\u041e\u0431\u0435\u0440\u043d\u0443\u0432 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0435 \u0432\u044b\u0448\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u0432 \u0434\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 \u2014 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0438 \u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u0435 \u2014 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0430\u043d\u0430\u043b\u043e\u0433 SignedCms, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043f\u0440\u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u043f\u0435\u0447\u0430\u0442\u043d\u043e\u0433\u043e \u0432\u0438\u0434\u0430 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435.<\/p>\n<p>  <\/p>\n<h3>\u0428\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h3>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u043e \u043c\u043d\u043e\u0433\u043e\u043c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u0435\u043d \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0443 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0438\u044f, \u043e\u043d \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043f\u0440\u043e\u0441\u0442, \u0438 \u043e\u0441\u043d\u043e\u0432\u043d\u0430\u044f \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u0442\u0430\u043a \u0436\u0435 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0438 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430. \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0438 \u043e\u0442 \u043f\u043e\u0434\u043f\u0438\u0441\u0438 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f \u0441\u0446\u0435\u043f\u043b\u0435\u043d\u043d\u043e\u0435 \u0432 \u0430\u0434\u0440\u0435\u0441 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u043b\u0438 \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0430\u0434\u0440\u0435\u0441\u0430\u0442\u043e\u0432 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0448\u0438\u0444\u0440\u0443\u044e\u0442 \u0435\u0449\u0435 \u0438 \u0432 \u0430\u0434\u0440\u0435\u0441 \u0441\u0435\u0431\u044f, \u0447\u0442\u043e\u0431\u044b \u0431\u044b\u043b\u0430 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0441\u0432\u043e\u0438\u043c \u043a\u043b\u044e\u0447\u043e\u043c).<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0417\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">\/**&lt;summary&gt;\u0417\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435&lt;\/summary&gt; * &lt;param name=&quot;_arInput&quot;&gt;\u0414\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0438&lt;\/param&gt; * &lt;param name=&quot;_pCert&quot;&gt;\u0421\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442&lt;\/param&gt; * &lt;param name=&quot;_arRes&quot;&gt;\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442&lt;\/param&gt; * &lt;param name=&quot;_sError&quot;&gt;\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439&lt;\/param&gt; * &lt;returns&gt;\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043a\u043e\u0434 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439, \u0435\u0441\u043b\u0438 UConsts.S_OK \u0442\u043e \u0432\u0441\u0435 \u043e\u043a&lt;\/returns&gt; * **\/ public static int EncryptDataCP(byte[] _arInput, X509Certificate2 _pCert, out byte[] _arRes, ref string _sError) {     _arRes = new byte[0];     try {         \/\/ 0) \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432         CRYPT_ENCRYPT_MESSAGE_PARA  pParams         = new CRYPT_ENCRYPT_MESSAGE_PARA();         pParams.dwMsgEncodingType                   = UCConsts.PKCS_7_OR_X509_ASN_ENCODING;         pParams.ContentEncryptionAlgorithm.pszObjId = _pCert.getEncodeAlgirtmOid();         pParams.cbSize = Marshal.SizeOf(pParams);         \/\/ 1) \u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0434\u043b\u0438\u043d\u044b         int iLen = 0;         if (!UCryptoAPI.CryptEncryptMessage(ref pParams, 1, new IntPtr[] { _pCert.getRealHandle() },                                             _arInput, _arInput.Length, null, ref iLen)) {             _sError = UCConsts.S_CRYPT_ENCODE_LEN_ERR.Frm(Marshal.GetLastWin32Error());             return UConsts.E_CRYPTO_ERR;         }         \/\/ 2) \u0412\u0442\u043e\u0440\u043e\u0439 \u0437\u0430\u043f\u0440\u043e\u0441 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0435 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435         _arRes = new byte[iLen];         if (!UCryptoAPI.CryptEncryptMessage(ref pParams, 1, new IntPtr[] {_pCert.getRealHandle() },                                            _arInput, _arInput.Length, _arRes, ref iLen)) {               _sError = UCConsts.S_CRYPT_ENCODE_ERR.Frm(Marshal.GetLastWin32Error());               return UConsts.E_CRYPTO_ERR;         }         return UConsts.S_OK;     } catch (Exception E) {         _sError = UCConsts.S_CRYPT_ENCODE_ERR.Frm(E.Message);         return UConsts.E_GEN_EXCEPTION;     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432 \u0442\u0440\u0438 \u044d\u0442\u0430\u043f\u0430 \u2014 \u0437\u0430\u043f\u043e\u043b\u043d\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0434\u043b\u0438\u043d\u044b \u0438 \u043d\u0430\u043a\u043e\u043d\u0435\u0446 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435. \u0417\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043c\u043e\u0433\u0443\u0442 \u0431\u044b\u0442\u044c \u0431\u043e\u043b\u044c\u0448\u0438\u0435, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043c\u0435\u0442\u043e\u0434 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u0442 \u0440\u0435\u0436\u0438\u043c \u0434\u0432\u0443\u0445 \u0432\u044b\u0437\u043e\u0432\u043e\u0432. <\/p>\n<p>  <\/p>\n<p>\u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0448\u0438\u0444\u0440\u0443\u0435\u0442\u0441\u044f \u0432 \u0430\u0434\u0440\u0435\u0441 \u043e\u0434\u043d\u043e\u0433\u043e \u0430\u0434\u0440\u0435\u0441\u0430\u0442\u0430, \u043d\u043e \u043f\u0443\u0442\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0445 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u043e\u0431\u0449\u0435\u0433\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u0430 \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043c\u0435\u0442\u043e\u0434\u0430, \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0442\u044c \u0447\u0438\u0441\u043b\u043e \u0430\u0434\u0440\u0435\u0441\u0430\u0442\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u0410 \u0432\u043e\u0442 \u0441 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u043c \u043e\u043f\u044f\u0442\u044c \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u044b. \u0412 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0435 \u043d\u0435\u0442 \u043d\u0438 \u0435\u0433\u043e, \u043d\u0438 \u0434\u0430\u0436\u0435 \u043a\u043e\u0441\u0432\u0435\u043d\u043d\u044b\u0445 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0435\u0433\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0431\u044b \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0438\u0442\u044c (\u043a\u0430\u043a \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0441 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u043c \u043f\u043e\u0434\u043f\u0438\u0441\u0438). \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u0435\u043c\u044b\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0438\u0437 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">\/**&lt;summary&gt;\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 OID \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0443&lt;\/summary&gt; * &lt;param name=&quot;_hCertHandle&quot;&gt;\u0425\u044d\u043d\u0434\u043b \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430&lt;\/param&gt; * &lt;param name=&quot;_sOID&quot;&gt;\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 OID&lt;\/param&gt; * &lt;param name=&quot;_sError&quot;&gt;\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439&lt;\/param&gt; * &lt;returns&gt;\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043a\u043e\u0434 \u043e\u0448\u0438\u0431\u043a\u0438, \u0435\u0441\u043b\u0438 UConsts.S_OK \u0442\u043e \u0432\u0441\u0435 \u043e\u043a&lt;\/returns&gt; * **\/ internal static int GetEncodeAlgoritmOID(IntPtr _hCertHandle, out string _sOID, ref string _sError) {     bool fNeedRelease = false;     _sOID = &quot;&quot;;     uint iKeySpec = 0;     IntPtr  hCrypto = IntPtr.Zero;     try {         \/\/ 0) \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u0430         if (!UCryptoAPI.CryptAcquireCertificatePrivateKey(_hCertHandle, 0, IntPtr.Zero,                                                           ref hCrypto, ref iKeySpec, ref fNeedRelease)) {             _sError = UCConsts.S_CRYPTO_PROV_INIT_ERR.Frm(Marshal.GetLastWin32Error());             return UConsts.E_CRYPTO_ERR;         }          uint iLen = 1000;         byte[] arData = new byte[1000];         uint iFlag = 1; \/\/ \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f         \/\/ 1) \u041f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u0432 \u0446\u0438\u043a\u043b\u0435 \u043f\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u043c         while (UCryptoAPI.CryptGetProvParam(hCrypto, UCConsts.PP_ENUMALGS, arData, ref iLen, iFlag)){             iFlag = 2; \/\/ \u0421\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439             PROV_ENUMALGS pInfo = ConvertBytesToStruct&lt;PROV_ENUMALGS&gt;(arData);             \/\/ 2) \u041f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c OID  \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u043c\u0442\u043e\u0432 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f             byte[]  arDataAlg = BitConverter.GetBytes(pInfo.aiAlgid);             IntPtr hDataAlg = Marshal.AllocHGlobal(arDataAlg.Length);             try {                 Marshal.Copy(arDataAlg, 0, hDataAlg, arDataAlg.Length);                 IntPtr hHashAlgInfo2 = UCryptoAPI.CryptFindOIDInfo(UCConsts.CRYPT_OID_INFO_ALGID_KEY,                                                                    hDataAlg,                                                                    UCConsts.CRYPT_ENCRYPT_ALG_OID_GROUP_ID);                 \/\/ 2.1) \u041d\u0430\u0448\u043b\u0438 - \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c                 if (hHashAlgInfo2 != IntPtr.Zero) {                     CRYPT_OID_INFO pHashAlgInfo2 = (CRYPT_OID_INFO)Marshal.PtrToStructure(hHashAlgInfo2,                                                                                           typeof(CRYPT_OID_INFO));                     _sOID = pHashAlgInfo2.pszOID ;                     return UConsts.S_OK;                 }             } finally {                  Marshal.FreeHGlobal(hDataAlg);             }         }         \/\/ 3) \u041d\u0435 \u043d\u0430\u0448\u043b\u0438 - \u043e\u0448\u0438\u0431\u043a\u0430         _sError = UCConsts.S_NO_ENCODE_ALG_ERR;         return UConsts.E_CRYPTO_ERR;     } catch (Exception E) {          _sError = UCConsts.S_DETERM_ENCODE_ALG_ERR.Frm(E.Message);         return UConsts.E_GEN_EXCEPTION;     }finally {         if((hCrypto != IntPtr.Zero) && fNeedRelease) UCryptoAPI.CryptReleaseContext(hCrypto, 0);     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0412 \u043f\u0440\u0438\u043c\u0435\u0440\u0435 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442\u0441\u044f \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0437\u0430\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0438 \u043f\u043e \u043d\u0435\u043c\u0443 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e\u0438\u0441\u043a \u043f\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430\u043c. \u041d\u043e \u0432 \u044d\u0442\u043e\u043c \u0441\u043f\u0438\u0441\u043a\u0435 \u043d\u0430\u0445\u043e\u0434\u044f\u0442\u0441\u044f \u0432\u0441\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b (\u043e\u0431\u043c\u0435\u043d\u0430 \u043a\u043b\u044e\u0447\u0435\u0439, \u0445\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043f\u043e\u0434\u043f\u0438\u0441\u0438, \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438 \u043f\u0440\u043e\u0447.), \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0430\u0434\u043e \u043e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u044b \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u041f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043f\u043e \u043a\u0430\u0436\u0434\u043e\u043c\u0443 \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0432\u0448\u0438\u0441\u044c \u0433\u0440\u0443\u043f\u043f\u043e\u0439 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f (UCConsts.CRYPT_ENCRYPT_ALG_OID_GROUP_ID). \u0418 \u0435\u0441\u043b\u0438 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043d\u0430\u0439\u0434\u0435\u043d\u0430 \u2014 \u0437\u043d\u0430\u0447\u0438\u0442 \u044d\u0442\u043e \u043d\u0430\u0448 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c.<\/p>\n<p>  <\/p>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u0438\u0445 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0431\u043e\u043b\u044c\u0448\u0435 \u0447\u0435\u043c \u043e\u0434\u0438\u043d \u043c\u043e\u0436\u043d\u043e \u0442\u0430\u043a \u0436\u0435 \u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c \u043f\u043e \u0440\u0430\u0437\u043c\u0435\u0440\u0443 (\u043e\u043f\u0438\u0440\u0430\u044f\u0441\u044c \u043d\u0430 \u0440\u0430\u0437\u043c\u0435\u0440 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0445\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f).<\/p>\n<p>  <\/p>\n<h3>\u0414\u0435\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h3>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0434\u0435\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435, \u043d\u0430 \u043b\u043e\u043a\u0430\u043b\u044c\u043d\u043e\u0439 \u043c\u0430\u0448\u0438\u043d\u0435 \u0432 \u043b\u0438\u0447\u043d\u044b\u0445 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430\u0445 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438\u043b\u0438 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440\u0430 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u0430\u0434\u0440\u0435\u0441\u0430\u0442\u043e\u0432. \u0418 \u043a \u043d\u0435\u043c\u0443 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0439 \u043a\u043b\u044e\u0447. \u041f\u0440\u043e\u0446\u0435\u0441\u0441 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442 \u043f\u043e \u0443\u0436\u0435 \u043f\u0440\u0438\u0432\u044b\u0447\u043d\u043e\u043c\u0443 \u0441\u0446\u0435\u043d\u0430\u0440\u0438\u044e \u2014 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0434\u043b\u0438\u043d\u044b \u0438 \u0441\u0430\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0434\u0435\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0414\u0435\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">\/**&lt;summary&gt;\u0414\u0435\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u0435\u0442 \u0434\u0430\u043d\u043d\u044b\u0435&lt;\/summary&gt; * &lt;param name=&quot;_arInput&quot;&gt;\u0414\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0438&lt;\/param&gt; * &lt;param name=&quot;_arRes&quot;&gt;\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442&lt;\/param&gt; * &lt;param name=&quot;_sError&quot;&gt;\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439&lt;\/param&gt; * &lt;param name=&quot;_pCert&quot;&gt;\u0421\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442&lt;\/param&gt; * &lt;returns&gt;\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0439 \u043a\u043e\u0434 \u043e\u0448\u0438\u0431\u043a\u0438, \u0435\u0441\u043b\u0438 UCOnsts.S_OK \u0442\u043e \u0432\u0441\u0435 \u043e\u043a&lt;\/returns&gt; * **\/ public static int DecryptDataCP(byte[] _arInput, out X509Certificate2 _pCert, out byte[] _arRes, ref string _sError) {                  _arRes = new byte[0];     _pCert = null;     IntPtr hSysStore =  UCryptoAPI.CertOpenSystemStore(IntPtr.Zero, UCConsts.AR_CRYPTO_STORE_NAME[(int)StoreName.My]);     GCHandle GC = GCHandle.Alloc(hSysStore, GCHandleType.Pinned);     IntPtr hOutCertL = IntPtr.Zero;     IntPtr hOutCert  = IntPtr.Zero;     try {         \/\/ 0) \u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u043a\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432         CRYPT_DECRYPT_MESSAGE_PARA pParams = new CRYPT_DECRYPT_MESSAGE_PARA();         pParams.dwMsgAndCertEncodingType = UCConsts.PKCS_7_OR_X509_ASN_ENCODING;         pParams.cCertStore = 1;         pParams.rghCertStore = GC.AddrOfPinnedObject();         pParams.cbSize = Marshal.SizeOf(pParams);         int iLen = 0;         \/\/ 1) \u041f\u0435\u0440\u0432\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0434\u043b\u0438\u043d\u0443          if (!UCryptoAPI.CryptDecryptMessage(ref pParams, _arInput, _arInput.Length,                                             null, ref iLen, ref hOutCertL)) {              _sError = UCConsts.S_DECRYPT_LEN_ERR.Frm(Marshal.GetLastWin32Error());             return UConsts.E_CRYPTO_ERR;         }         \/\/ 2) \u0412\u0442\u043e\u0440\u043e\u0439  \u0432\u044b\u0437\u043e\u0432 \u0434\u0435\u0448\u0438\u0444\u0440\u0443\u0435\u043c         _arRes = new byte[iLen];         if (!UCryptoAPI.CryptDecryptMessage(ref pParams, _arInput, _arInput.Length,                                            _arRes, ref iLen, ref hOutCert)) {             _sError = UCConsts.S_DECRYPT_ERR.Frm(Marshal.GetLastWin32Error());             return UConsts.E_CRYPTO_ERR;         }         \/\/ 3) \u0415\u0441\u043b\u0438 \u0435\u0441\u0442\u044c \u0432\u044b\u0442\u0430\u0441\u043a\u0438\u0432\u0430\u0435\u043c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442         if (hOutCert != IntPtr.Zero) _pCert = new ISDP_X509Cert(hOutCert);         if(_pCert != null) hOutCert = IntPtr.Zero;         \/\/ \u0412\u0441\u0435 \u043e\u043a \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c         return UConsts.S_OK;     } catch (Exception E) {          _sError = UCConsts.S_DECRYPT_ERR.Frm(E.Message);         return UConsts.E_GEN_EXCEPTION;     } finally {         if (hOutCertL != IntPtr.Zero) UCryptoAPI.CertFreeCertificateContext(hOutCertL);         if (hOutCert != IntPtr.Zero) UCryptoAPI.CertFreeCertificateContext(hOutCert);         GC.Free();         UCryptoAPI.CertCloseStore(hSysStore, 0);     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041f\u0440\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u044b\u0442\u0430\u0442\u044c\u0441\u044f \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u043f\u043e\u0434\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 \u0441 \u043a\u043b\u044e\u0447\u043e\u043c. \u0412 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u0440\u0430\u0431\u043e\u0442\u044b \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0432\u044b\u0434\u0430\u0441\u0442 \u0434\u0435\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d (\u0432 Linux \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 \u0432\u0441\u0435\u0433\u0434\u0430 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f \u043f\u0443\u0441\u0442\u043e\u0439). <\/p>\n<p>  <\/p>\n<h3>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430<\/h3>\n<p>  <\/p>\n<p>\u0421\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 \u044d\u0442\u043e \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0439 \u043a\u043b\u044e\u0447, \u043d\u043e \u0435\u0449\u0435 \u0438 \u043d\u0430\u0431\u043e\u0440 \u0440\u0430\u0437\u043d\u043e\u0439 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u0435\u0433\u043e \u0432\u043b\u0430\u0434\u0435\u043b\u044c\u0446\u0435, \u043e \u0442\u043e\u043c, \u043a\u0442\u043e \u0435\u0433\u043e \u0432\u044b\u0434\u0430\u043b \u0438 \u043e \u043d\u0430\u0431\u043e\u0440\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0441 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u043c\u043e\u0436\u043d\u043e \u0434\u0435\u043b\u0430\u0442\u044c. \u0422\u0430\u043a \u0436\u0435 \u0443 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 \u0435\u0441\u0442\u044c \u043f\u0435\u0440\u0438\u043e\u0434 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0438 \u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e\u0441\u0442\u044c \u043e\u0442\u0437\u044b\u0432\u0430, \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043a\u043e\u043c\u043f\u0440\u043e\u043c\u0435\u0442\u0430\u0446\u0438\u0438. \u0427\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u043f\u043e\u0434 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u043e\u0439 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 \u043f\u043e\u0434\u0440\u0430\u0437\u0443\u043c\u0435\u0432\u0430\u0435\u0442\u0441\u044f \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0435: <\/p>\n<p>  <\/p>\n<ol>\n<li>\u0446\u0435\u043b\u043e\u0441\u0442\u043d\u043e\u0441\u0442\u044c \u0446\u0435\u043f\u043e\u0447\u043a\u0438 (\u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 \u0438\u0437\u0434\u0430\u0442\u0435\u043b\u044f, \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 \u0438\u0437\u0434\u0430\u0442\u0435\u043b\u044f \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 \u0438\u0437\u0434\u0430\u0442\u0435\u043b\u044f, \u0438 \u0442.\u00a0\u043f.);<\/li>\n<li>\u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0433\u043e \u0438\u0437\u0434\u0430\u0442\u0435\u043b\u044f \u2014 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0434\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u0445 \u043a\u043e\u0440\u043d\u0435\u0432\u044b\u0445 \u0446\u0435\u043d\u0442\u0440\u043e\u0432;<\/li>\n<li>\u043f\u0435\u0440\u0438\u043e\u0434 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0432\u0441\u0435\u0445 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u2014 \u043c\u043e\u043c\u0435\u043d\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c \u0432 \u0433\u0440\u0430\u043d\u0438\u0446\u0430\u0445 \u044d\u0442\u043e\u0433\u043e \u043f\u0435\u0440\u0438\u043e\u0434\u0430;  <\/li>\n<li>\u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u0432 \u0446\u0435\u043f\u043e\u0447\u043a\u0435, \u043a\u0440\u043e\u043c\u0435 \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0433\u043e, \u0434\u043e\u043b\u0436\u0435\u043d \u043e\u0442\u0441\u0443\u0442\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u043f\u0438\u0441\u043a\u0435 \u043e\u0442\u043e\u0437\u0432\u0430\u043d\u043d\u044b\u0445 \u0443 \u0441\u0432\u043e\u0435\u0433\u043e \u0438\u0437\u0434\u0430\u0442\u0435\u043b\u044f (CRL);<\/li>\n<\/ol>\n<p>  <\/p>\n<p>\u041f\u043e \u0445\u043e\u0440\u043e\u0448\u0435\u043c\u0443 \u043d\u0430\u0434\u043e \u0435\u0449\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u0438 \u043f\u0440\u0430\u0432\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u0438, \u043d\u043e \u0432 \u0440\u0435\u0430\u043b\u044c\u043d\u043e\u0439 \u0436\u0438\u0437\u043d\u0438 \u044d\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442\u0441\u044f \u0440\u0435\u0434\u043a\u043e.<\/p>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0443\u0436\u0435 \u043f\u043e\u043d\u044f\u0442\u043d\u043e \u0438\u0437 \u0432\u0432\u0435\u0434\u0435\u043d\u0438\u044f, \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 \u043d\u0430 \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0441\u0442\u044c, \u043e\u0434\u043d\u0430 \u0438\u0437 \u0441\u0430\u043c\u044b\u0445 \u0441\u043b\u043e\u0436\u043d\u044b\u0445 \u0437\u0430\u0434\u0430\u0447. \u0418\u043c\u0435\u043d\u043d\u043e \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u043c\u0430\u0441\u0441\u0430 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0434\u043b\u044f \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0438\u0437 \u043f\u0443\u043d\u043a\u0442\u043e\u0432 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443, \u0434\u043b\u044f \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u0438\u044f \u043e\u0431\u0440\u0430\u0442\u0438\u043c\u0441\u044f \u043a \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0430\u043c .Net \u0434\u043b\u044f \u043c\u0435\u0442\u043e\u0434\u0430 <a href=\"https:\/\/referencesource.microsoft.com\/#System\/security\/system\/security\/cryptography\/x509\/x509certificate2.cs,1132\">X509Certificate2.Verify()<\/a> \u0438 \u0432\u043e\u0437\u044c\u043c\u0435\u043c \u0438\u0445 \u0437\u0430 \u043e\u0441\u043d\u043e\u0432\u0443.<\/p>\n<p>  \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0434\u0432\u0443\u0445 \u044d\u0442\u0430\u043f\u043e\u0432:  <\/p>\n<ol>\n<li>\u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u0432\u043f\u043b\u043e\u0442\u044c \u0434\u043e \u043a\u043e\u0440\u043d\u0435\u0432\u043e\u0433\u043e;<\/li>\n<li>\u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043a\u0430\u0436\u0434\u044b\u0439 \u0438\u0437 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u0432 \u043d\u0435\u0439 (\u043d\u0430 \u043e\u0442\u0437\u044b\u0432, \u0432\u0440\u0435\u043c\u044f \u0438 \u043f\u0440\u043e\u0447.);<\/li>\n<\/ol>\n<p>  <\/p>\n<p>\u0422\u0430\u043a\u0430\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0434\u043e\u043b\u0436\u043d\u0430 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0442\u044c\u0441\u044f \u043f\u0435\u0440\u0435\u0434 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0438\u0435\u043c \u0438 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u043d\u0430 \u0442\u0435\u043a\u0443\u0449\u0443\u044e \u0434\u0430\u0442\u0443, \u0438 \u0432 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u0438 \u043d\u0430 \u0434\u0430\u0442\u0443 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0438\u044f. \u0421\u0430\u043c \u043c\u0435\u0442\u043e\u0434 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u043d\u0435\u0431\u043e\u043b\u044c\u0448\u043e\u0439:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">\/**&lt;summary&gt;\u041f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442&lt;\/summary&gt; * &lt;param name=&quot;_iRevFlag&quot;&gt;\u0424\u043b\u0430\u0433 \u043e\u0442\u0437\u044b\u0432\u0430&lt;\/param&gt; * &lt;param name=&quot;_iRevMode&quot;&gt;\u0420\u0435\u0436\u0438\u043c \u043e\u0442\u0437\u044b\u0432\u0430&lt;\/param&gt; * &lt;param name=&quot;_hPolicy&quot;&gt;\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438&lt;\/param&gt; * &lt;param name=&quot;_hCert&quot;&gt;\u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0441\u0435\u0440\u0442\u0444\u0438\u043a\u0430\u0442\u0430&lt;\/param&gt; * &lt;param name=&quot;_iCTLTimeout&quot;&gt;\u0442\u0430\u0439\u043c\u0430\u0443\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0441\u043f\u0438\u0441\u043a\u0430 \u043e\u0442\u0437\u044b\u0432\u0430&lt;\/param&gt; * &lt;param name=&quot;_rOnDate&quot;&gt;\u0414\u0430\u0442\u0430 \u0432\u0435\u0440\u0438\u0444\u0438\u043a\u0430\u0446\u043c\u043c&lt;\/param&gt; * &lt;param name=&quot;_sError&quot;&gt;\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439&lt;\/param&gt; * &lt;returns&gt;\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u044b\u0439 \u043a\u043e\u0434 \u043e\u0448\u0438\u0431\u043a\u0438, \u0435\u0441\u043b\u0438 UConsts.S_OK \u0442\u043e \u0432\u0441\u0435 \u043e\u043a&lt;\/returns&gt; * **\/ internal static int VerifyCertificate (IntPtr _hCert, X509RevocationMode _iRevMode, X509RevocationFlag _iRevFlag,                                         DateTime _rOnDate, TimeSpan _iCTLTimeout, IntPtr _hPolicy, ref string _sError) {      if (_hCert == IntPtr.Zero) {         _sError = UCConsts.S_CRYPTO_CERT_CHECK_ERR;         return UConsts.E_NO_CERTIFICATE;     }     CERT_CHAIN_POLICY_PARA   pPolicyParam  = new CERT_CHAIN_POLICY_PARA(Marshal.SizeOf(typeof(CERT_CHAIN_POLICY_PARA)));     CERT_CHAIN_POLICY_STATUS pPolicyStatus = new CERT_CHAIN_POLICY_STATUS(Marshal.SizeOf(typeof(CERT_CHAIN_POLICY_STATUS)));      \/\/ 1) \u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0446\u0435\u043f\u043e\u0447\u043a\u0443     IntPtr hChain = IntPtr.Zero;     try {         int iRes = BuildChain(new IntPtr(UCConsts.HCCE_CURRENT_USER), _hCert, __iRevMode, _iRevFlag,                              _rOnDate, _iCTLTimeout, ref hChain, ref _sError);         if (iRes != UConsts.S_OK) return iRes;         \/\/ 2) \u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c \u0446\u0435\u043f\u043e\u0447\u043a\u0443         if (UCryptoAPI.CertVerifyCertificateChainPolicy(_hPolicy, hChain, ref pPolicyParam, ref pPolicyStatus)) {             if (pPolicyStatus.dwError != 0) {                 _sError = UCConsts.S_CRYPTO_CHAIN_CHECK_ERR.Frm(pPolicyStatus.dwError);                 return UConsts.E_CRYPTO_ERR;             }          } else{             _sError = UCConsts.S_CRYPTO_CHAIN_CHECK_ERR.Frm(Marshal.GetLastWin32Error());             return UConsts.E_CRYPTO_ERR;         }         return UConsts.S_OK;     } catch (Exception E) {         _sError = UCConsts.S_CRYPTO_CERT_VERIFY_GEN_ERR.Frm(E.Message);         return UConsts.E_GEN_EXCEPTION;     } finally {         if(hChain != IntPtr.Zero) UCryptoAPI.CertFreeCertificateChain(hChain);     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0446\u0435\u043f\u043e\u0447\u043a\u0430 \u043c\u0435\u0442\u043e\u0434\u043e\u043c BuildChain, \u0430 \u0437\u0430\u0442\u0435\u043c \u043e\u043d\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442\u0441\u044f. \u0412 \u0445\u043e\u0434\u0435 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432, \u0434\u0430\u0442\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0438 \u0444\u043b\u0430\u0433\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0424\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">\/**&lt;summary&gt;\u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 \u0446\u0435\u043f\u043e\u0447\u043a\u0443 \u0441\u0435\u0440\u0442\u0444\u0438\u043a\u0438\u0430\u0442\u0430 \u0434\u043b\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438&lt;\/summary&gt; * &lt;param name=&quot;_hChain&quot;&gt;\u041a\u041e\u043d\u0442\u0435\u043a\u0441\u0442 \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u0441\u0435\u0440\u0442\u0444\u0438\u0438\u043a\u0430\u0442\u043e\u0432&lt;\/param&gt; * &lt;param name=&quot;_iRevFlag&quot;&gt;\u0424\u043b\u0430\u0433 \u043e\u0442\u0437\u044b\u0432\u0430&lt;\/param&gt; * &lt;param name=&quot;_iRevMode&quot;&gt;\u0420\u0435\u0436\u0438\u043c \u043e\u0442\u0437\u044b\u0432\u0430&lt;\/param&gt; * &lt;param name=&quot;_hChainEngine&quot;&gt;\u0422\u0438\u043f \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430&lt;\/param&gt; * &lt;param name=&quot;_hCert&quot;&gt;\u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0441\u0435\u0440\u0442\u0444\u0438\u043a\u0430\u0442\u0430&lt;\/param&gt; * &lt;param name=&quot;_rCTLTimeOut&quot;&gt;\u0442\u0430\u0439\u043c\u0430\u0443\u0442 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0441\u043f\u0438\u0441\u043a\u0430 \u043e\u0442\u0437\u044b\u0432\u0430&lt;\/param&gt; * &lt;param name=&quot;_rOnDate&quot;&gt;\u0414\u0430\u0442\u0430 \u0432\u0435\u0440\u0438\u0444\u0438\u043a\u0430\u0446\u043c\u043c&lt;\/param&gt; * &lt;param name=&quot;_sError&quot;&gt;\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439&lt;\/param&gt; * &lt;returns&gt;\u0421\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u044b\u0439 \u043a\u043e\u0434 \u043e\u0448\u0438\u0431\u043a\u0438, \u0435\u0441\u043b\u0438 UConsts.S_OK \u0442\u043e \u0432\u0441\u0435 \u043e\u043a&lt;\/returns&gt; * **\/ internal static int BuildChain (IntPtr _hChainEngine, IntPtr _hCert, X509RevocationMode _iRevMode,                                  X509RevocationFlag _iRevFlag, DateTime _rOnDate, TimeSpan _rCTLTimeOut,                                  ref IntPtr _hChain, ref string _sError) {     \/\/ 0) \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043d\u0430\u043b\u0438\u0447\u0438\u044f \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430     if (_hCert == IntPtr.Zero) {         _sError = UCConsts.S_CRYPTO_CERT_CHAIN_ERR;         return UConsts.E_NO_CERTIFICATE;     }     \/\/ 1) \u041f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b     CERT_CHAIN_PARA pChainParams = new CERT_CHAIN_PARA();     pChainParams.cbSize = (uint) Marshal.SizeOf(pChainParams);      IntPtr hAppPolicy = IntPtr.Zero;     IntPtr hCertPolicy = IntPtr.Zero;     try {         \/\/ 2) \u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u044f         pChainParams.dwUrlRetrievalTimeout = (uint)Math.Floor(_rCTLTimeOut.TotalMilliseconds);         \/\/ 3) \u0412\u0440\u0435\u043c\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438         FILETIME pVerifyTime = new FILETIME(_rOnDate.ToFileTime());         \/\/ 4) \u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0444\u043b\u0430\u0433         uint _iFlags = MapRevocationFlags(_iRevMode, _iRevFlag);         \/\/ 5) \u0424\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0446\u0435\u043f\u043e\u0447\u043a\u0438         if (!UCryptoAPI.CertGetCertificateChain(_hChainEngine, _hCert, ref pVerifyTime,                                                 IntPtr.Zero, ref pChainParams, _iFlags,                                                 IntPtr.Zero, ref _hChain)) {             _sError = UCConsts.S_CRYPTO_CHAIN_BUILD_ERR.Frm(Marshal.GetLastWin32Error());             return UConsts.E_CRYPTO_ERR;         }     } catch(Exception E) {          _sError = UCConsts.S_CRYPTO_CHAIN_GEN_ERR.Frm(E.Message);         return UConsts.E_GEN_EXCEPTION;     } finally {         Marshal.FreeHGlobal(hAppPolicy);         Marshal.FreeHGlobal(hCertPolicy);     }     return UConsts.S_OK; } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u042d\u0442\u043e \u0441\u0438\u043b\u044c\u043d\u043e \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u043f\u043e \u0441\u0440\u0430\u0432\u043d\u0435\u043d\u0438\u044e \u0441 \u0442\u0435\u043c, \u043a\u0430\u043a \u0435\u0435 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 Microsoft. \u0421\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b hCertPolicy \u0438 hAppPolicy \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u043e\u043b\u043d\u0438\u0442\u044c OID-\u0430\u043c\u0438, \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u044e\u0449\u0438\u043c\u0438 \u043f\u0440\u0430\u0432\u0430 \u043d\u0430 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b \u0432 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c\u043e\u043c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0435. \u041d\u043e \u0432 \u043f\u0440\u0438\u043c\u0435\u0440\u0435, \u0431\u0443\u0434\u0435\u043c \u0441\u0447\u0438\u0442\u0430\u0442\u044c, \u0447\u0442\u043e \u0438\u0445 \u043c\u044b \u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u043c.<\/p>\n<p>  <\/p>\n<p>\u0422\u0430\u043a \u0436\u0435 \u043c\u043e\u0436\u043d\u043e \u0432 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u044b \u043f\u043e\u0441\u0442\u0440\u043e\u0435\u043d\u0438\u044f \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u043d\u043e\u0435 \u0438\u0437 \u043f\u043e\u0434\u043f\u0438\u0441\u0438).<\/p>\n<p>  <\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/referencesource.microsoft.com\/#System\/security\/system\/security\/cryptography\/x509\/x509utils.cs,158\">MapRevocationFlags<\/a> \u2014 \u043c\u043e\u0436\u043d\u043e \u0432\u0437\u044f\u0442\u044c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0438\u0437 \u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432 .Net \u0431\u0435\u0437 \u0438\u0437\u043c\u0435\u043d\u0435\u043d\u0438\u0439 \u2014\u043e\u043d \u043f\u0440\u043e\u0441\u0442\u043e \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442 uint \u043f\u043e \u043d\u0430\u0431\u043e\u0440\u0443 \u043f\u0435\u0440\u0435\u0434\u0430\u0432\u0430\u0435\u043c\u044b\u0445 \u0444\u043b\u0430\u0433\u043e\u0432.<\/p>\n<p>  <\/p>\n<h3>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h3>\n<p>  <\/p>\n<p>\u041d\u0430\u0431\u043e\u0440 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0435\u0439 \u0431\u044b\u043b \u043f\u043e\u0434\u0432\u0435\u0440\u0433\u043d\u0443\u0442 \u043d\u0430\u0433\u0440\u0443\u0437\u043e\u0447\u043d\u043e\u043c\u0443 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044e \u043f\u043e \u0441\u0445\u0435\u043c\u0435 \u0446\u0438\u043a\u043b\u0430 \u043f\u043e\u043b\u043d\u043e\u0439 \u0440\u0430\u0431\u043e\u0442\u044b:<\/p>\n<p>  <\/p>\n<ol>\n<li>\u043e\u0436\u0438\u0434\u0430\u043d\u0438\u0435 10 \u043c\u0441;<\/li>\n<li>\u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430;<\/li>\n<li>\u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0438\u0435 byte[] {1, 2, 3, 4, 5};<\/li>\n<li>\u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0439 \u043f\u043e\u0434\u043f\u0438\u0441\u0438;<\/li>\n<li>\u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u043e\u0434\u043f\u0438\u0441\u0438;<\/li>\n<li>\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 byte[] {1, 2, 3, 4, 5};<\/li>\n<li>\u0434\u0435\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445;<\/li>\n<\/ol>\n<p>  <\/p>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u0446\u0438\u043a\u043b \u0431\u044b\u043b \u0437\u0430\u043f\u0443\u0449\u0435\u043d \u0432 Windows \u0438 \u0432 Linux \u0432 1-\u043e\u043c, 10-\u0438 \u0438 50-\u0438 \u043f\u043e\u0442\u043e\u043a\u0430\u0445, \u0447\u0442\u043e\u0431\u044b \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0440\u0430\u0431\u043e\u0442\u0443 \u0432 Linux \u0441\u0440\u0430\u0437\u0443 \u0432 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u043f\u043e\u0442\u043e\u043a\u0430\u0445. \u041f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0432 Linux \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u043e \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e \u0432 \u0442\u0435\u0447\u0435\u043d\u0438\u0438 \u043a\u0430\u043a\u043e\u0433\u043e-\u0442\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 \u0432\u043e \u043c\u043d\u043e\u0433\u043e-\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u043c \u0440\u0435\u0436\u0438\u043c\u0435 (\u0438 \u0447\u0435\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u0442\u043e\u043a\u043e\u0432, \u0442\u0435\u043c \u043c\u0435\u043d\u044c\u0448\u0435 \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438), \u0430 \u0437\u0430\u0442\u0435\u043c \u00ab\u0432\u0441\u0442\u0430\u0432\u0430\u043b\u043e\u00bb \u043d\u0430\u0433\u043b\u0443\u0445\u043e. \u0427\u0442\u043e \u0441\u0432\u0438\u0434\u0435\u0442\u0435\u043b\u044c\u0441\u0442\u0432\u0443\u0435\u0442 \u043e \u043d\u0430\u043b\u0438\u0447\u0438\u0438 \u0432\u0437\u0430\u0438\u043c\u043d\u043e\u0439 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438 (deadlock-\u0435) \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 (\u043f\u0440\u0438 \u043d\u0430\u0440\u0443\u0448\u0435\u043d\u0438\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u043f\u043e\u0442\u043e\u043a\u0430\u043c\u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0441 \u0440\u0430\u0437\u0434\u0435\u043b\u044f\u0435\u043c\u044b\u043c \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u043c \u043e\u0431\u044b\u0447\u043d\u043e \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0430\u0434\u0435\u043d\u0438\u0435 \u0441 \u00abAccess Violation\u00bb).<\/p>\n<p>  <\/p>\n<p>\u041f\u043e \u044d\u0442\u043e\u0439 \u043f\u0440\u0438\u0447\u0438\u043d\u0435 \u0434\u043b\u044f \u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0435\u043d\u0438\u044f \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0432\u0441\u0435 \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u043b\u0430\u0441\u0441\u0430 UCryptoAPI \u0441\u0442\u043e\u0438\u0442 \u043e\u0431\u0440\u0430\u043c\u0438\u0442\u044c \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0435\u043a\u0446\u0438\u0435\u0439. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u043e\u043b\u0435 fpCPSection \u0442\u0438\u043f\u0430 object \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0432 \u043a\u0430\u0436\u0434\u044b\u0439 \u0432\u044b\u0437\u043e\u0432 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0443\u044e \u043a\u043e\u043d\u0441\u0442\u0440\u0443\u043a\u0446\u0438\u044e:<\/p>\n<p>  <\/p>\n<pre><code class=\"cs\">private static object fpCPSection = new object(); \/**&lt;summary&gt;\u0417\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u0442 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435&lt;\/summary&gt; * &lt;param name=&quot;_hCryptMsg&quot;&gt;\u0423\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435&lt;\/param&gt; * **\/ internal static bool CryptMsgClose(IntPtr _hCryptMsg) {     lock (pCPSection) {         if (fIsLinux)             return LCryptoAPI.CryptMsgClose(_hCryptMsg);         else             return WCryptoAPI.CryptMsgClose(_hCryptMsg);     } } \/**&lt;summary&gt;\u041a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u0435\u043a\u0446\u0438\u044f \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u041a\u0440\u0438\u043f\u0442\u043e\u041f\u0440\u043e&lt;\/summary&gt;**\/ public static object pCPSection {     get { return fpCPSection;} } <\/code><\/pre>\n<p>  <\/p>\n<p>\u042d\u0442\u043e \u0437\u0430\u043c\u0435\u0434\u043b\u044f\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0436\u0435\u043b\u0430\u044e\u0449\u0438\u0435 \u043c\u043e\u0433\u0443\u0442 \u043e\u0431\u0440\u0430\u043c\u043b\u044f\u0442\u044c \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0435\u043a\u0446\u0438\u0435\u0439 \u0442\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u0437\u043e\u0432 Linux- \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430.<\/p>\n<p>  <\/p>\n<p>\u041d\u0430\u0433\u0440\u0443\u0437\u043e\u0447\u043d\u043e\u0435 \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0442\u0430\u043a \u0436\u0435 \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u043e \u0443\u0442\u0435\u0447\u043a\u0438 \u043f\u0430\u043c\u044f\u0442\u0438 \u0432 mono \u043f\u0440\u0438 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0438 \u043a \u043f\u043e\u043b\u044f\u043c Issuer \u0438 Subject \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430. \u0423\u0442\u0435\u0447\u043a\u0430, \u0432\u0435\u0440\u043e\u044f\u0442\u043d\u043e, \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 mono \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u043a\u043b\u0430\u0441\u0441\u044b X500DistinguishedName \u0434\u043b\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u0430 \u0438 \u0438\u0437\u0434\u0430\u0442\u0435\u043b\u044f. \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, mono \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u043b\u0438 \u044d\u0442\u043e\u0442 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0440\u0435\u0441\u0443\u0440\u0441\u043e\u0435\u043c\u043a\u0438\u043c (\u0438\u043b\u0438 \u0436\u0435 \u043e\u043d\u0438 \u0437\u043d\u0430\u044e\u0442 \u043e\u0431 \u0443\u0442\u0435\u0447\u043a\u0435), \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0435\u0434\u0443\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u043a\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0430 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0432\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0435 \u043f\u043e\u043b\u044f \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 (impl.issuerName \u0438 impl.subjectName). \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0434\u0430\u043d\u043d\u0430\u044f \u0443\u0442\u0435\u0447\u043a\u0430 \u043b\u0435\u0447\u0438\u0442\u0441\u044f \u043f\u0440\u044f\u043c\u043e\u0439 \u0437\u0430\u043f\u0438\u0441\u044c\u044e \u0447\u0435\u0440\u0435\u0437 \u043e\u0442\u0440\u0430\u0436\u0435\u043d\u0438\u0435 (Reflection) \u0432 \u044d\u0442\u0438 \u043f\u043e\u043b\u044f \u044d\u043a\u0437\u0435\u043c\u043f\u043b\u044f\u0440\u043e\u0432 \u043a\u043b\u0430\u0441\u0441\u0430 X500DistinguishedName, \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0445 \u043d\u0430 \u0431\u0430\u0437\u0435 \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0439 \u0438\u0437 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b CERT_CONTEXT \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430.<\/p>\n<p>  <\/p>\n<h2>\u0421\u0441\u044b\u043b\u043a\u0438<\/h2>\n<p>  <\/p>\n<ol>\n<li><a href=\"http:\/\/cpdn.cryptopro.ru\/\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f <\/a>\u041a\u0440\u0438\u043f\u0442\u043e\u041f\u0440\u043e CAPILite <\/li>\n<li><a href=\"https:\/\/www.pinvoke.net\/\">\u0440\u0435\u0441\u0443\u0440\u0441 <\/a>c \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0435\u043c \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u044b\u0445 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u0435\u043c\u044b\u0445 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u0432 \u0421#<\/li>\n<li>\u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 .Net:<br \/> \n<ol>\n<li>\u043a\u043b\u0430\u0441\u0441 <a href=\"https:\/\/referencesource.microsoft.com\/#System\/security\/system\/security\/cryptography\/cryptoapi.cs,28\">CAPIBase<\/a><\/li>\n<li>\u043a\u043b\u0430\u0441\u0441 <a href=\"https:\/\/referencesource.microsoft.com\/#System\/security\/system\/security\/cryptography\/x509\/x509certificate2.cs,279\">X509Certificate2<\/a><\/li>\n<li>\u043a\u043b\u0430\u0441\u0441 <a href=\"https:\/\/referencesource.microsoft.com\/#System.Security\/system\/security\/cryptography\/pkcs\/signedpkcs7.cs,24\">SignedCMS<\/a><\/li>\n<li>\u043a\u043b\u0430\u0441\u0441 <a href=\"https:\/\/referencesource.microsoft.com\/#System.Security\/system\/security\/cryptography\/pkcs\/signerinfo.cs,23\">SignerInfo<\/a><\/li>\n<\/ol>\n<p>   <\/li>\n<li>\u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 mono:<br \/> \n<ol>\n<li>\u043a\u043b\u0430\u0441\u0441 <a href=\"https:\/\/github.com\/mono\/mono\/blob\/master\/mcs\/class\/System\/System.Security.Cryptography.X509Certificates\/X509Certificate2.cs\">X509Certificate2<\/a><\/li>\n<li>\u043a\u043b\u0430\u0441\u0441 <a href=\"https:\/\/github.com\/mono\/mono\/blob\/master\/mcs\/class\/System\/Mono.Btls\/X509CertificateImplBtls.cs\">X509CertificateImplBtls<\/a><\/li>\n<\/ol>\n<p>  <\/li>\n<\/ol>\n<\/div>\n<p>        <script class=\"js-mediator-script\">!function(e){function t(t,n){if(!(n in e)){for(var r,a=e.document,i=a.scripts,o=i.length;o--;)if(-1!==i[o].src.indexOf(t)){r=i[o];break}if(!r){r=a.createElement(\"script\"),r.type=\"text\/javascript\",r.async=!0,r.defer=!0,r.src=t,r.charset=\"UTF-8\";var d=function(){var e=a.getElementsByTagName(\"script\")[0];e.parentNode.insertBefore(r,e)};\"[object Opera]\"==e.opera?a.addEventListener?a.addEventListener(\"DOMContentLoaded\",d,!1):e.attachEvent(\"onload\",d):d()}}}t(\"\/\/mediator.mail.ru\/script\/2820404\/\",\"_mediator\")}(window);<\/script>     <br \/> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/post\/423163\/\"> https:\/\/habr.com\/post\/423163\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\n<p>\u0412 \u0441\u0432\u044f\u0437\u0438 \u0441 \u043f\u0435\u0440\u0435\u0445\u043e\u0434\u043e\u043c \u043d\u0430 Linux \u0432\u043e\u0437\u043d\u0438\u043a\u043b\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0430 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043d\u0430\u0448\u0438\u0445 \u0441\u0435\u0440\u0432\u0435\u0440\u043d\u044b\u0445 \u0441\u0438\u0441\u0442\u0435\u043c \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0439 \u043d\u0430 C# \u0432 Mono. \u0421\u0438\u0441\u0442\u0435\u043c\u0430 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0441 \u0443\u0441\u0438\u043b\u0435\u043d\u043d\u044b\u043c\u0438 \u042d\u0426\u041f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0434\u043d\u043e\u0439 \u0438\u0437 \u043f\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u043f\u0435\u0440\u0435\u0434 \u043d\u0430\u043c\u0438 \u0437\u0430\u0434\u0430\u0447 \u0431\u044b\u043b\u0430 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0440\u0430\u0431\u043e\u0442\u043e\u0441\u043f\u043e\u0441\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0413\u041e\u0421\u0422\u043e\u0432\u044b\u0445 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u043e\u0442 \u041a\u0440\u0438\u043f\u0442\u043e\u041f\u0440\u043e \u0432 mono. \u0421\u0430\u043c \u041a\u0440\u0438\u043f\u0442\u043e\u041f\u0440\u043e \u0443\u0436\u0435 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0434\u0430\u0432\u043d\u043e \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b <a href=\"https:\/\/www.cryptopro.ru\/products\/csp\/compare\">CSP <\/a>\u043f\u043e\u0434 Linux, \u043d\u043e \u043f\u0435\u0440\u0432\u0430\u044f \u0436\u0435 \u043f\u043e\u043f\u044b\u0442\u043a\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u043a\u0430\u0437\u0430\u043b\u0430, \u0447\u0442\u043e \u043d\u0430\u0442\u0438\u0432\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0438 Mono (\u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u044b\u0435 \u0442\u0435\u043c, \u0447\u0442\u043e \u0435\u0441\u0442\u044c \u0432 \u0431\u0430\u0437\u043e\u0432\u043e\u043c .Net \u2014 X509Store, X509Certificate2 \u0438 \u043f\u0440\u043e\u0447.) \u043d\u0435 \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u044e\u0442 \u0441 \u0413\u041e\u0421\u0422\u043e\u0432\u044b\u043c\u0438 \u043a\u043b\u044e\u0447\u0430\u043c\u0438, \u043e\u043d\u0438 \u0434\u0430\u0436\u0435 \u043d\u0435 \u0432\u0438\u0434\u044f\u0442 \u0438\u0445 \u0432 \u0441\u0432\u043e\u0438\u0445 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430\u0445. \u0412 \u0441\u0438\u043b\u0443 \u044d\u0442\u043e\u0433\u043e \u0440\u0430\u0431\u043e\u0442\u0443 \u0441 \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0435\u0439 \u043f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0447\u0435\u0440\u0435\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u041a\u0440\u0438\u043f\u0442\u043e\u041f\u0440\u043e.<\/p>\n<p>  <\/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-289354","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/289354","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=289354"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/289354\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=289354"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=289354"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=289354"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}