{"id":289616,"date":"2018-09-19T16:15:02","date_gmt":"2018-09-19T12:15:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=289616"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=289616","title":{"rendered":"\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 OpenSSL \u0432 Mono"},"content":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\n<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u044b\u043b \u043e\u043f\u0438\u0441\u0430\u043d \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 \u0413\u041e\u0421\u0422\u043e\u0432\u044b\u0445 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u041a\u0440\u0438\u043f\u0442\u043e\u041f\u0440\u043e \u0441 mono. \u0412 \u044d\u0442\u043e\u0439 \u0436\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c\u0441\u044f \u043d\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 RSA \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u043b\u0438 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u0442\u044c \u043e\u0434\u043d\u0443 \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\u044b\u0445 \u043d\u0430 C# \u0432 Linux, \u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0434\u043e\u0448\u043b\u0430 \u0434\u043e \u0447\u0430\u0441\u0442\u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0439 \u0441 RSA. \u0415\u0441\u043b\u0438 \u0432 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0432 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043b\u0435\u0433\u043a\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u043b\u0438\u0441\u044c \u043d\u0430\u043b\u0438\u0447\u0438\u0435\u043c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0434\u0432\u0443\u0445, \u0438\u0441\u0445\u043e\u0434\u043d\u043e \u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c \u0441\u0438\u0441\u0442\u0435\u043c, \u0442\u043e \u043f\u0440\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u00ab\u043e\u0431\u044b\u0447\u043d\u044b\u0445\u00bb RSA \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u043e\u0442 mono \u044f\u0432\u043d\u043e \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u043e\u0436\u0438\u0434\u0430\u043b \u043f\u043e\u0434\u0432\u043e\u0445\u0430.<\/p>\n<p>  <a name=\"habracut\"><\/a>  <\/p>\n<p>\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 \u0438 \u043a\u043b\u044e\u0447\u0430 \u043f\u0440\u043e\u0431\u043b\u0435\u043c \u043d\u0435 \u0432\u044b\u0437\u0432\u0430\u043b\u0430, \u0438 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0434\u0430\u0436\u0435 \u0443\u0432\u0438\u0434\u0435\u043b\u0430 \u0435\u0433\u043e \u0432 \u0448\u0442\u0430\u0442\u043d\u043e\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435. \u041e\u0434\u043d\u0430\u043a\u043e \u043d\u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u0442\u044c, \u043d\u0438 \u0437\u0430\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c, \u043d\u0438 \u0432\u044b\u0442\u0430\u0449\u0438\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 \u0440\u0430\u043d\u0435\u0435 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u043f\u043e\u0434\u043f\u0438\u0441\u0438 \u0443\u0436\u0435 \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0430\u043b\u043e\u0441\u044c \u2014 mono \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e \u043f\u0430\u0434\u0430\u043b\u043e \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439. \u041f\u0440\u0438\u0448\u043b\u043e\u0441\u044c \u043a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u041a\u0440\u0438\u043f\u0442\u043e\u041f\u0440\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043a \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f. \u0414\u043b\u044f RSA \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u0432 Linux \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043a\u0430\u043d\u0434\u0438\u0434\u0430\u0442 \u0434\u043b\u044f \u0442\u0430\u043a\u043e\u0433\u043e \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u2014 OpenSSL.<\/p>\n<p>  <\/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>\u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e Centos 7 \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u0432\u0441\u0442\u0440\u043e\u0435\u043d\u043d\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0435\u0439 OpenSSL \u2014 1.0.2k. \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u0432\u043d\u043e\u0441\u0438\u0442\u044c \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0432 \u0440\u0430\u0431\u043e\u0442\u0443 \u0441\u0438\u0441\u0442\u0435\u043c\u044b, \u0440\u0435\u0448\u0438\u043b\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0442\u044c\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u043a \u044d\u0442\u043e\u0439 \u0432\u0435\u0440\u0441\u0438\u0438. OpenSSL \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0430\u0439\u043b\u043e\u0432\u044b\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432, \u043e\u0434\u043d\u0430\u043a\u043e:<\/p>\n<p>  <\/p>\n<ol>\n<li>\u0442\u0430\u043a\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u044b \u0438 CRL, \u0430 \u043d\u0435 \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0435 \u043a\u043b\u044e\u0447\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0445 \u0432 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e;<\/li>\n<li>\u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u0438 \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0445 \u043a\u043b\u044e\u0447\u0435\u0439 \u0432 Windows \u043d\u0430 \u0434\u0438\u0441\u043a\u0435 \u0432 \u043d\u0435\u0437\u0430\u0449\u0438\u0449\u0435\u043d\u043d\u043e\u043c \u0432\u0438\u0434\u0435 \u2014 \u00ab\u043a\u0440\u0430\u0439\u043d\u0435 \u043d\u0435\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u00bb (\u043e\u0442\u0432\u0435\u0442\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u0435 \u0437\u0430 \u0446\u0438\u0444\u0440\u043e\u0432\u0443\u044e \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0441\u0442\u044c \u043e\u0431\u044b\u0447\u043d\u043e \u043e\u043f\u0438\u0441\u044b\u0432\u0430\u044e\u0442 \u044d\u0442\u043e \u0431\u043e\u043b\u0435\u0435 \u0435\u043c\u043a\u043e \u0438 \u043c\u0435\u043d\u0435\u0435 \u0446\u0435\u043d\u0437\u0443\u0440\u043d\u043e), \u0447\u0435\u0441\u0442\u043d\u043e \u0433\u043e\u0432\u043e\u0440\u044f, \u044d\u0442\u043e \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e \u0438 \u0432 Linux, \u043d\u043e, \u043f\u043e \u0444\u0430\u043a\u0442\u0443, \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0440\u0430\u0441\u043f\u0440\u043e\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u043d\u043e\u0439 \u043f\u0440\u0430\u043a\u0442\u0438\u043a\u043e\u0439;<\/li>\n<li>\u0441\u043e\u0433\u043b\u0430\u0441\u043e\u0432\u044b\u0432\u0430\u0442\u044c \u043c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0445 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449 \u0432 Windows \u0438 Linux \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430\u0442\u0438\u0447\u043d\u043e;<\/li>\n<li>\u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0440\u0443\u0447\u043d\u043e\u0439 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430, \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0443\u0442\u0438\u043b\u0438\u0442\u0430 \u0434\u043b\u044f \u0443\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0438\u044f \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432;<\/li>\n<li>mono \u0441\u0430\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 \u0434\u0438\u0441\u043a\u043e\u0432\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0441\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 OpenSSL, \u0438 \u0442\u0430\u043a \u0436\u0435 \u0440\u044f\u0434\u043e\u043c \u0432 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u043c \u0432\u0438\u0434\u0435 \u0445\u0440\u0430\u043d\u0438\u0442 \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0435 \u043a\u043b\u044e\u0447\u0438;<\/li>\n<\/ol>\n<p>  \u0412 \u0441\u0438\u043b\u0443 \u044d\u0442\u0438\u0445 \u043f\u0440\u0438\u0447\u0438\u043d \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0434\u043b\u044f \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f OpenSSL \u0448\u0442\u0430\u0442\u043d\u044b\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 .Net \u0438 mono. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0432 Linux \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 \u0438 \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0439 \u043a\u043b\u044e\u0447 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u0435\u0434\u0432\u0430\u0440\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043f\u043e\u043c\u0435\u0441\u0442\u0438\u0442\u044c \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 mono.   <\/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\">\u0412\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u0441\u044f \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u0448\u0442\u0430\u0442\u043d\u043e\u0439 \u0443\u0442\u0438\u043b\u0438\u0442\u043e\u0439 certmgr. \u0412 \u043d\u0430\u0447\u0430\u043b\u0435 \u0438\u043d\u0441\u0442\u0430\u043b\u043b\u0438\u0440\u0443\u0435\u043c \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0439 \u043a\u043b\u044e\u0447 \u0438\u0437 pfx:<br \/>  <code>certmgr -importKey -c -p {password} My {pfx file}<\/code><br \/>  \u0417\u0430\u0442\u0435\u043c \u0441\u0442\u0430\u0432\u0438\u043c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 \u0438\u0437 \u044d\u0442\u043e\u0433\u043e pfx, \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0439 \u043a\u043b\u044e\u0447 \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0438\u0442\u0441\u044f \u043a \u043d\u0435\u043c\u0443:<br \/>  <code>certmgr -add -c My {cer file}<\/code><br \/>  \u0415\u0441\u043b\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u043a\u043b\u044e\u0447 \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0434\u043b\u044f \u043c\u0430\u0448\u0438\u043d\u044b, \u0442\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043e\u043f\u0446\u0438\u044e -m. \u041f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 \u043c\u043e\u0436\u043d\u043e \u0443\u0432\u0438\u0434\u0435\u0442\u044c \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435:<br \/>  <code>certmgr -list -c -v My<\/code><br \/>  \u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u0432\u044b\u0434\u0430\u0447\u0443. \u0412 \u043d\u0435\u0439 \u0434\u043e\u043b\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u043e\u0442\u043c\u0435\u0447\u0435\u043d\u043e, \u0447\u0442\u043e \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 \u0432\u0438\u0434\u0435\u043d \u0441\u0438\u0441\u0442\u0435\u043c\u043e\u0439, \u0438 \u043f\u0440\u0438\u0432\u044f\u0437\u0430\u043d \u043a \u0437\u0430\u043a\u0440\u044b\u0442\u043e\u043c\u0443 \u043a\u043b\u044e\u0447\u0443 \u0437\u0430\u0433\u0440\u0443\u0436\u0435\u043d\u043d\u043e\u043c\u0443 \u0440\u0430\u043d\u0435\u0435. \u041f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\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.  <\/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>\u0422\u0430\u043a \u0436\u0435 \u043a\u0430\u043a \u0438 \u0432 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437 \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u043d\u0435\u0441\u043c\u043e\u0442\u0440\u044f \u043d\u0430 \u043f\u0435\u0440\u0435\u043d\u043e\u0441 \u0432 Linux \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. \u041f\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 \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>\u0412 \u0438\u0434\u0435\u0430\u043b\u0435 \u0434\u043e\u043b\u0436\u043d\u044b \u0431\u044b\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0440\u0430\u0431\u043e\u0442\u0430\u043b\u0438 \u0431\u044b \u043a\u0430\u043a \u0438 \u0432 Windows \u2014 \u043d\u0435\u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e \u043e\u0442 \u0442\u0438\u043f\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 (\u0432 Linux \u0447\u0435\u0440\u0435\u0437 OpenSSL \u0438\u043b\u0438 \u041a\u0440\u0438\u043f\u0442\u043e\u041f\u0440\u043e \u0432 \u0437\u0430\u0432\u0438\u0441\u0438\u043c\u043e\u0441\u0442\u0438 \u043e\u0442 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430, \u0430 \u0432 Windows \u2013 \u0447\u0435\u0440\u0435\u0437 crypt32).<\/p>\n<p>  <\/p>\n<p>\u0410\u043d\u0430\u043b\u0438\u0437 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a OpenSSL, \u043f\u043e\u043a\u0430\u0437\u0430\u043b, \u0447\u0442\u043e \u0432 Windows \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439 \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u00ablibeay32.dll\u00bb, \u0430 \u0432 Linux \u00ablibcrypto.so.10\u00bb. \u0422\u0430\u043a \u0436\u0435 \u043a\u0430\u043a \u0438 \u0432 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0434\u0432\u0430 \u043a\u043b\u0430\u0441\u0441\u0430 WOpenSSLAPI \u0438 LOpenSSLAPI, \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0438\u0435 \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438:  <\/p>\n<pre><code class=\"cs\">[DllImport(CTRYPTLIB, CharSet = CharSet.Auto, SetLastError = true, CallingConvention = CallingConvention.Cdecl)] internal static extern void OPENSSL_init(); <\/code><\/pre>\n<p>  <\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043a\u043e\u043d\u0432\u0435\u043d\u0446\u0438\u044e \u0432\u044b\u0437\u043e\u0432\u0430, \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0438 \u043e\u0442 \u041a\u0440\u0438\u043f\u0442\u043e\u041f\u0440\u043e \u2014 \u0437\u0434\u0435\u0441\u044c \u0435\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u044f\u0432\u043d\u043e \u0443\u043a\u0430\u0437\u0430\u0442\u044c. \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 \u0432 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \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 \u043d\u0430 \u0431\u0430\u0437\u0435 *.h <a href=\"https:\/\/github.com\/openssl\/openssl\/tree\/master\/include\/openssl\">\u0444\u0430\u0439\u043b\u043e\u0432 <\/a>\u0438\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u043e\u0432 OpenSSL. <\/p>\n<p>  <\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u044b\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u0430 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0438\u043d\u0442\u0430\u043a\u0441\u0438\u0441\u0430 \u0432\u044b\u0437\u043e\u0432\u0430 \u0432 \u0421# \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 .h \u0444\u0430\u0439\u043b\u043e\u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0435:<\/p>\n<p>  <\/p>\n<ol>\n<li>\u043b\u044e\u0431\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b, \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u043f\u0440\u043e\u0447\u0435\u0435 \u2014 IntPtr, \u0432 \u0442\u043e\u043c \u0447\u0438\u0441\u043b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u0432\u043d\u0443\u0442\u0440\u0438 \u0441\u0430\u043c\u0438\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440;<\/li>\n<li>\u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0441\u0441\u044b\u043b\u043a\u0438 \u2014 ref IntPtr, \u0435\u0441\u043b\u0438 \u0442\u0430\u043a\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043d\u0435 \u0441\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0435\u0442, \u0442\u043e \u043f\u0440\u043e\u0441\u0442\u043e IntPtr. \u0412 \u0442\u0430\u043a\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0430\u043c\u0443 \u0441\u0441\u044b\u043b\u043a\u0443 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0442\u044c \u0438 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u0432\u0440\u0443\u0447\u043d\u0443\u044e;<\/li>\n<li>\u043c\u0430\u0441\u0441\u0438\u0432\u044b \u2014 byte[];<\/li>\n<li>long \u0432 \u0421 (OpenSSL) \u044d\u0442\u043e int \u0432 \u0421# (\u043c\u0430\u043b\u0435\u043d\u044c\u043a\u0430\u044f, \u043d\u0430 \u043f\u0435\u0440\u0432\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434, \u043e\u0448\u0438\u0431\u043a\u0430 \u043c\u043e\u0436\u0435\u0442 \u043e\u0431\u0435\u0440\u043d\u0443\u0442\u044c\u0441\u044f \u0447\u0430\u0441\u0430\u043c\u0438 \u043f\u043e\u0438\u0441\u043a\u0430 \u0438\u0441\u0442\u043e\u0447\u043d\u0438\u043a\u0430 \u043d\u0435\u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0443\u0435\u043c\u044b\u0445 \u043e\u0448\u0438\u0431\u043e\u043a);<\/li>\n<\/ol>\n<p>  <\/p>\n<p>\u0412 \u043e\u0431\u044a\u044f\u0432\u043b\u0435\u043d\u0438\u0438 \u043c\u043e\u0436\u043d\u043e, \u043f\u043e \u043f\u0440\u0438\u0432\u044b\u0447\u043a\u0435, \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u0442\u044c SetLastError = true, \u043d\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u044d\u0442\u043e \u043f\u0440\u043e\u0438\u0433\u043d\u043e\u0440\u0438\u0440\u0443\u0435\u0442 \u2014 \u043e\u0448\u0438\u0431\u043a\u0438 \u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u0434\u043e\u0441\u0442\u0443\u043f\u043d\u044b \u0447\u0435\u0440\u0435\u0437 Marshal.GetLastWin32Error(). \u0414\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043e\u0448\u0438\u0431\u043a\u0430\u043c \u0443 OpenSSL \u0441\u0432\u043e\u0438 \u043c\u0435\u0442\u043e\u0434\u044b.<\/p>\n<p>  <\/p>\n<p>\u0410 \u0437\u0430\u0442\u0435\u043c \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0443\u0436\u0435 \u0437\u043d\u0430\u043a\u043e\u043c\u044b\u0439 \u0441\u0442\u0430\u0442\u0438\u0447\u0435\u0441\u043a\u0438\u0439 \u043a\u043b\u0430\u0441\u0441 \u00abUOpenSSLAPI\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\">private static object fpOSSection = new object(); \/**&lt;summary&gt;\u0418\u043d\u0438\u0446\u0438\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 OpenSSL&lt;\/summary&gt;**\/ public static void OPENSSL_init() {     lock (pOSSection) {         if (fIsLinux)             LOpenSSLAPI.OPENSSL_init();         else             WOpenSSLAPI.OPENSSL_init();     } } \/**&lt;summary&gt;\u041a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0430\u044f \u0441\u0435\u043a\u0446\u0438\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u0432 OpenSSL&lt;\/summary&gt;**\/ public static object pOSSection {     get { return fpOSSection; } } \/**&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>\u0421\u0442\u0440\u0430\u0437\u0443 \u043e\u0442\u043c\u0435\u0442\u0438\u043c \u043d\u0430\u043b\u0438\u0447\u0438\u0435 \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0435\u043a\u0446\u0438\u0438. OpenSSL <a href=\"https:\/\/www.openssl.org\/blog\/blog\/2017\/02\/21\/threads\/\">\u0442\u0435\u043e\u0440\u0435\u0442\u0438\u0447\u0435\u0441\u043a\u0438 <\/a>\u043e\u0431\u0435\u0441\u043f\u0435\u0447\u0438\u0432\u0430\u0435\u0442 \u0440\u0430\u0431\u043e\u0442\u0443 \u0432 \u043c\u043d\u043e\u0433\u043e-\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u043c \u043e\u043a\u0440\u0443\u0436\u0435\u043d\u0438\u0438. \u041d\u043e, \u0432\u043e \u043f\u0435\u0440\u0432\u044b\u0445, \u0441\u0440\u0430\u0437\u0443 \u0432 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0438 \u0441\u043a\u0430\u0437\u0430\u043d\u043e, \u0447\u0442\u043e \u044d\u0442\u043e \u043d\u0435 \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u0435\u0442\u0441\u044f:<\/p>\n<p>  <\/p>\n<blockquote><p>But you still can\u2019t concurrently use most objects in multiple threads.<\/p><\/blockquote>\n<p>  <\/p>\n<p>\u0410 \u0432\u043e \u0432\u0442\u043e\u0440\u044b\u0445, \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043d\u0435 \u0441\u0430\u043c\u044b\u0439 \u0442\u0440\u0438\u0432\u0438\u0430\u043b\u044c\u043d\u044b\u0439. \u041e\u0431\u044b\u0447\u043d\u0430\u044f \u0434\u0432\u0443\u0445 \u044f\u0434\u0435\u0440\u043d\u0430\u044f VM (\u0441\u0435\u0440\u0432\u0435\u0440 \u0441 \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u043e\u0440\u043e\u043c Intel Xeon E5649 \u0432 \u0440\u0435\u0436\u0438\u043c\u0435 Hyper-Threading) \u043f\u0440\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0438 \u0442\u0430\u043a\u043e\u0439 \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u043e\u0439 \u0441\u0435\u043a\u0446\u0438\u0438 \u0434\u0430\u0435\u0442 \u043e\u043a\u043e\u043b\u043e 100 \u043f\u043e\u043b\u043d\u044b\u0445 \u0446\u0438\u043a\u043b\u043e\u0432 (\u0441\u043c. \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0437 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 <a href=\"https:\/\/habr.com\/post\/423163\/\">\u0441\u0442\u0430\u0442\u044c\u0438<\/a>) \u0438\u043b\u0438 600 \u043f\u043e\u0434\u043f\u0438\u0441\u0435\u0439 \u0432 \u0441\u0435\u043a\u0443\u043d\u0434\u0443, \u0447\u0442\u043e \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0434\u043b\u044f \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u0430 \u0437\u0430\u0434\u0430\u0447 (\u043f\u0440\u0438 \u0431\u043e\u043b\u044c\u0448\u0438\u0445 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u0430\u0445 \u0432\u0441\u0435 \u0440\u0430\u0432\u043d\u043e \u0431\u0443\u0434\u0435\u0442 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u043a\u043e\u0440\u0435\u0435 \u043c\u0438\u043a\u0440\u043e\u0441\u0435\u0440\u0432\u0438\u0441\u043d\u0430\u044f \u0438\u043b\u0438 \u0443\u0437\u043b\u043e\u0432\u0430\u044f \u0430\u0440\u0445\u0438\u0442\u0435\u043a\u0442\u0443\u0440\u0430 \u0441\u0438\u0441\u0442\u0435\u043c\u044b). <\/p>\n<p>  <\/p>\n<h2>\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0438 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0430 OpenSSL<\/h2>\n<p>  <\/p>\n<p>\u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0438 \u043e\u0442 \u041a\u0440\u0438\u043f\u0442\u043e\u041f\u0440\u043e OpenSSL \u0442\u0440\u0435\u0431\u0443\u0435\u0442 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439 \u043f\u0435\u0440\u0435\u0434 \u0442\u0435\u043c \u043a\u0430\u043a \u043d\u0430\u0447\u0430\u0442\u044c \u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438 \u043f\u043e\u0441\u043b\u0435 \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u043e\u0439:  <\/p>\n<pre><code class=\"cs\">\/**&lt;summary&gt;\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f OpenSSL&lt;\/summary&gt;**\/ public static void InitOpenSSL() {     UOpenSSLAPI.OPENSSL_init();     UOpenSSLAPI.ERR_load_crypto_strings();     UOpenSSLAPI.ERR_load_RSA_strings();     UOpenSSLAPI.OPENSSL_add_all_algorithms_conf();     UOpenSSLAPI.OpenSSL_add_all_ciphers();     UOpenSSLAPI.OpenSSL_add_all_digests(); } \/**&lt;summary&gt;\u041e\u0447\u0438\u0441\u0442\u043a\u0430 OpenSSL&lt;\/summary&gt;**\/ public static void CleanupOpenSSL() {     UOpenSSLAPI.EVP_cleanup();     UOpenSSLAPI.CRYPTO_cleanup_all_ex_data();     UOpenSSLAPI.ERR_free_strings(); } <\/code><\/pre>\n<h2>\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0430\u0445<\/h2>\n<p>  <\/p>\n<p>OpenSSL \u0445\u0440\u0430\u043d\u0438\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0430\u0445 \u0432\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0438\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430\u0445 \u0434\u043b\u044f \u0434\u043e\u0441\u0442\u0443\u043f\u0430 \u043a \u043a\u043e\u0442\u043e\u0440\u044b\u043c, \u0432 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435 \u0435\u0441\u0442\u044c \u0441\u043f\u0435\u0446\u0438\u0430\u043b\u044c\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b. \u041a \u0441\u043e\u0436\u0430\u043b\u0435\u043d\u0438\u044e, \u0447\u0430\u0441\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u044b\u0445 \u043c\u0435\u0442\u043e\u0434\u043e\u0432, \u0442\u0430\u043a\u0438\u0445 \u043a\u0430\u043a ERR_error_string \u2014 \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 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0431\u043e\u043b\u0435\u0435 \u0441\u043b\u043e\u0436\u043d\u044b\u0435 \u043c\u0435\u0442\u043e\u0434\u044b: <\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e\u0431 \u043e\u0448\u0438\u0431\u043a\u0430\u0445<\/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 \u0441\u0442\u0440\u043e\u043a\u0443 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439 OpenSSL&lt;\/summary&gt; * &lt;param name=\"_iErr\"&gt;\u041a\u043e\u0434 \u043e\u0448\u0438\u0431\u043a\u0438&lt;\/param&gt; * &lt;param name=\"_iPart\"&gt;\u0420\u0430\u0437\u0434\u0435\u043b&lt;\/param&gt; * &lt;returns&gt;\u0421\u0442\u0440\u043e\u043a\u0430 \u043e\u0448\u0438\u0431\u043a\u0438&lt;\/returns&gt; * **\/ public static string GetErrStrPart(ulong _iErr, int _iPart) {     \/\/ 0) \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0442\u0438\u043f \u0441\u0442\u0440\u043e\u043a\u0438     IntPtr hErrStr = IntPtr.Zero;     switch (_iPart) {         case 0: hErrStr = UOpenSSLAPI.ERR_lib_error_string(_iErr);                 break;         case 1: hErrStr = UOpenSSLAPI.ERR_func_error_string(_iErr);                 break;         case 2: hErrStr = UOpenSSLAPI.ERR_reason_error_string(_iErr);                 break;     }     \/\/ 1) \u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0441\u0440\u043e\u043a\u0443     return PtrToFirstStr(hErrStr); } \/**&lt;summary&gt;\u0421\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439 OpenSSL&lt;\/summary&gt; * &lt;param name=\"_iErr\"&gt;\u041a\u043e\u0434 \u043e\u0448\u0438\u0431\u043a\u0438&lt;\/param&gt; * &lt;returns&gt;\u0421\u0442\u0440\u043e\u043a\u0430 \u043e\u0448\u0438\u0431\u043a\u0438&lt;\/returns&gt; * **\/ public static string GetErrStr(ulong _iErr ) {     return UCConsts.S_GEN_LIB_ERR_MAKRO.Frm(_iErr, GetErrStrPart(_iErr, 0),                                             GetErrStrPart(_iErr, 1),                                              GetErrStrPart(_iErr, 2)); } \/**&lt;summary&gt;\u0421\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0442\u0440\u043e\u043a\u0443 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439 OpenSSL&lt;\/summary&gt; * &lt;returns&gt;\u0421\u0442\u0440\u043e\u043a\u0430 \u043e\u0448\u0438\u0431\u043a\u0438&lt;\/returns&gt; * **\/         public static string GetErrStrOS() {     return GetErrStr(UOpenSSLAPI.ERR_get_error()); } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041e\u0448\u0438\u0431\u043a\u0430 \u0432 OpenSSL \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0435, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u043e\u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u043e\u0448\u043b\u0430, \u043c\u0435\u0442\u043e\u0434\u0435 \u0438 \u043f\u0440\u0438\u0447\u0438\u043d\u0435. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u043e\u0441\u043b\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0441\u0430\u043c\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u043e\u0448\u0438\u0431\u043a\u0438, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0432\u0441\u0435 \u044d\u0442\u0438 \u0442\u0440\u0438 \u0447\u0430\u0441\u0442\u0438 \u043f\u043e \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438 \u0441\u0432\u0435\u0441\u0442\u0438 \u0432\u043c\u0435\u0441\u0442\u0435 \u0432 \u0442\u0435\u043a\u0441\u0442\u043e\u0432\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0435. \u0414\u043b\u0438\u043d\u044b \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438, \u043a\u0430\u043a \u0443\u0442\u0432\u0435\u0440\u0436\u0434\u0430\u0435\u0442 <a href=\"https:\/\/www.openssl.org\/docs\/man1.0.2\/crypto\/ERR_lib_error_string.html#DESCRIPTION\">\u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u044f <\/a>OpenSSL \u043d\u0435 \u043f\u0440\u0435\u0432\u044b\u0448\u0430\u044e\u0442 120 \u0441\u0438\u043c\u0432\u043e\u043b\u043e\u0432, \u0438 \u0442.\u00a0\u043a. \u043c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u044b\u0439 \u043a\u043e\u0434, \u0442\u043e \u0441\u0442\u0440\u043e\u043a\u0443 \u043d\u0430\u0434\u043e \u0430\u043a\u043a\u0443\u0440\u0430\u0442\u043d\u043e \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u043f\u043e \u0441\u0441\u044b\u043b\u043a\u0435:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u043f\u043e IntPtr<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">\/**&lt;summary&gt;\u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0438\u0437 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u043f\u0435\u0440\u0432\u044b\u0439 PChar \u0438\u0437 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043f\u0430\u043c\u044f\u0442\u0438  \u0434\u043b\u0438\u043d\u043d\u043e\u0439 _iLen&lt;\/summary&gt; * &lt;param name=\"_hPtr\"&gt;\u0423\u043a\u0430\u0437\u0435\u0442\u0435\u043b\u044c \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&lt;\/param&gt; * &lt;param name=\"_iLen\"&gt;\u0414\u043b\u0438\u043d\u0430 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u043f\u0430\u043c\u044f\u0442\u0438&lt;\/param&gt; * &lt;returns&gt;\u0418\u0442\u043e\u0433\u043e\u0432\u0430\u044f \u0441\u0442\u0440\u043e\u043a\u0430&lt;\/returns&gt; * **\/ public static string PtrToFirstStr(IntPtr _hPtr, int _iLen = 256) {     if(_hPtr == IntPtr.Zero) return \"\";     try {         byte[] arStr = new byte[_iLen];         Marshal.Copy(_hPtr, arStr, 0, arStr.Length);         string[] arRes = Encoding.ASCII.GetString(arStr).Split(new char[] { (char)0 },                                                                 StringSplitOptions.RemoveEmptyEntries);         if (arRes.Length &gt; 0) return arRes[0];           return \"\";     }catch {           return \"\";     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041e\u0448\u0438\u0431\u043a\u0438 \u043f\u0440\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u0432 \u043e\u0431\u0449\u0438\u0439 \u0441\u043f\u0438\u0441\u043e\u043a, \u0438 \u0438\u0445 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c, \u043f\u043e \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0443 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432\u0435\u0440\u0438\u0444\u0438\u043a\u0430\u0446\u0438\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;\u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u0432\u0435\u0440\u0438\u0444\u0438\u043a\u0430\u0446\u0438\u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430&lt;\/summary&gt; * &lt;param name=\"_hStoreCtx\"&gt;\u041a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430&lt;\/param&gt; * &lt;returns&gt;\u0421\u0442\u0440\u043e\u043a\u0430 \u043e\u0448\u0438\u0431\u043a\u0438&lt;\/returns&gt; * **\/ public static string GetCertVerifyErr(IntPtr _hStoreCtx) {     int iErr = UOpenSSLAPI.X509_STORE_CTX_get_error(_hStoreCtx);     return PtrToFirstStr(UOpenSSLAPI.X509_verify_cert_error_string(iErr)); } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<h2>\u041f\u043e\u0438\u0441\u043a \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430<\/h2>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0438 \u0432\u0441\u0435\u0433\u0434\u0430, \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u044f \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. \u041c\u044b \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0448\u0442\u0430\u0442\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438 \u0438\u0441\u043a\u0430\u0442\u044c \u0431\u0443\u0434\u0435\u043c \u0448\u0442\u0430\u0442\u043d\u044b\u043c\u0438 \u043c\u0435\u0442\u043e\u0434\u0430\u043c\u0438:<\/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=\"_pFindType\"&gt;\u0422\u0438\u043f \u043f\u043e\u0438\u0441\u043a\u0430&lt;\/param&gt; * &lt;param name=\"_pFindValue\"&gt;\u0417\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043f\u043e\u0438\u0441\u043a\u0430&lt;\/param&gt; * &lt;param name=\"_pLocation\"&gt;\u041c\u0435\u0441\u0442\u043e &lt;\/param&gt; * &lt;param name=\"_pName\"&gt;\u0418\u043c\u044f \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430&lt;\/param&gt; * &lt;param name=\"_pCert\"&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=\"_sError\"&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=\"_fVerify\"&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; * **\/ internal static int FindCertificateOS(string _pFindValue, out X509Certificate2 _pCert, ref string _sError,                                        StoreLocation _pLocation = StoreLocation.CurrentUser,                                        StoreName _pName = StoreName.My,                                        X509FindType _pFindType = X509FindType.FindByThumbprint,                                                                                    bool _fVerify = false) {     lock (UOpenSSLAPI.pOSSection) {         \/\/ 0) \u0421\u0437\u0434\u0430\u0435\u043c \u043d\u0430\u0442\u0438\u0432\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435         _pCert = null;         X509Store pStore = new X509Store(_pName, _pLocation);         X509Certificate2Collection pCerts = null;         try {             \/\/ 1) \u041e\u0442\u043a\u0440\u044b\u0442\u0438\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430             pStore.Open(OpenFlags.ReadOnly);             \/\/ 2) \u041f\u043e\u0438\u0441\u043a \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 (\u043d\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u044f, \u0442.\u043a. Verify \u0432 Linux \u0432\u0441\u0435\u0433\u0434\u0430 false)             pCerts = pStore.Certificates.Find(_pFindType, _pFindValue, false);             if (pCerts.Count == 0) return UConsts.E_NO_CERTIFICATE;             \/\/ 3) \u041d\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u043f\u0435\u0440\u0432\u044b\u0439             if (!_fVerify) {                 _pCert = ISDP_X509Cert.Create(pCerts[0], TCryptoPath.cpOpenSSL);                 return UConsts.S_OK;             }             \/\/ 4) \u041f\u0440\u043e\u0445\u043e\u0434\u0438\u043c \u043f\u043e \u0441\u0435\u0440\u0442\u0444\u0438\u043a\u0430\u0442\u0430\u043c \u0438 \u0432\u044b\u0431\u0438\u0440\u0430\u0435\u043c \u0432\u0430\u043b\u0438\u0434\u043d\u044b\u0439             foreach (X509Certificate2 pCert in pCerts) {                 ISDP_X509Cert pISDPCert = ISDP_X509Cert.Create(pCert, TCryptoPath.cpOpenSSL);                 if (pISDPCert.ISDPVerify()) {                     _pCert = pISDPCert;                      return UConsts.S_OK;                 }             }             return UConsts.E_NO_CERTIFICATE;         } finally {             if(pCerts != null) pCerts.Clear();             pStore.Close();         }     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041e\u0431\u0440\u0430\u0442\u0438\u0442\u0435 \u0432\u043d\u0438\u043c\u0430\u043d\u0438\u0435 \u043d\u0430 \u043a\u0440\u0438\u0442\u0438\u0447\u0435\u0441\u043a\u0443\u044e \u0441\u0435\u043a\u0446\u0438\u044e. Mono \u0441 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430\u043c\u0438 \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0442\u0430\u043a \u0436\u0435 \u0447\u0435\u0440\u0435\u0437 OpenSSL, \u043d\u043e \u043d\u0435 \u0447\u0435\u0440\u0435\u0437 UOpenSSLAPI. \u0415\u0441\u043b\u0438 \u0435\u0435 \u0437\u0434\u0435\u0441\u044c \u043d\u0435 \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0438 \u0443\u0442\u0435\u0447\u043a\u0438 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u043f\u043b\u0430\u0432\u0430\u044e\u0449\u0438\u0435 \u043d\u0435\u043f\u043e\u043d\u044f\u0442\u043d\u044b\u0435 \u043e\u0448\u0438\u0431\u043a\u0438 \u043f\u043e\u0434 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439.<\/p>\n<p>  <\/p>\n<p>\u041e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430. \u0412 \u043e\u0442\u043b\u0438\u0447\u0438\u0438 \u043e\u0442 \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430 \u0434\u043b\u044f \u041a\u0440\u0438\u043f\u0442\u043e\u041f\u0440\u043e \u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0438\u0437 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u0430\u043c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 (X509Certificate2), \u0438 \u0441\u0441\u044b\u043b\u043a\u0430 \u0432 Handle \u0432 \u043d\u0435\u043c \u0443\u0436\u0435 \u043d\u0430\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u0430 \u043d\u0430 OpenSSL \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 X509_st. \u041a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0431\u044b \u044d\u0442\u043e \u0442\u043e, \u0447\u0442\u043e \u043d\u0430\u0434\u043e, \u043d\u043e \u0432\u043e\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044f \u043d\u0430 EVP_PKEY (\u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0437\u0430\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0432 OpenSSL) \u0432 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0435 \u043d\u0435\u0442.   <\/p>\n<p>\u0421\u0430\u043c \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0439 \u043a\u043b\u044e\u0447, \u043a\u0430\u043a \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c, \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \u0432 \u043e\u0442\u043a\u0440\u044b\u0442\u043e\u043c \u0432\u0438\u0434\u0435 \u0432\u043e \u0432\u043d\u0443\u0442\u0440\u0435\u043d\u043d\u0435\u043c \u043f\u043e\u043b\u0435 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 \u2014 impl\/fallback\/_cert\/_rsa\/rsa. \u042d\u0442\u043e \u043a\u043b\u0430\u0441\u0441 RSAManaged, \u0438 \u0431\u0435\u0433\u043b\u044b\u0439 \u0432\u0437\u0433\u043b\u044f\u0434 \u043d\u0430 \u0435\u0433\u043e \u043a\u043e\u0434 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043d\u0430 \u043c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/github.com\/mono\/mono\/blob\/776e31141400017e7262bf76d456ec07733db8a1\/mcs\/class\/Mono.Security\/Mono.Security.Cryptography\/RSAManaged.cs#L177\">DecryptValue<\/a>) \u043f\u043e\u043a\u0430\u0437\u044b\u0432\u0430\u0435\u0442 \u043d\u0430 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432 mono \u0432\u0441\u0435 \u043f\u043b\u043e\u0445\u043e \u0441 \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0435\u0439. \u0412\u043c\u0435\u0441\u0442\u043e \u0442\u043e\u0433\u043e, \u0447\u0442\u043e\u0431\u044b \u0447\u0435\u0441\u0442\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u044b \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0438 OpenSSL, \u043e\u043d\u0438, \u0441\u0443\u0434\u044f \u043f\u043e \u0432\u0441\u0435\u043c\u0443, \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u0438 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0432\u0440\u0443\u0447\u043d\u0443\u044e. \u042d\u0442\u043e \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u043e\u0434\u043a\u0440\u0435\u043f\u043b\u044f\u0435\u0442\u0441\u044f \u043f\u0443\u0441\u0442\u044b\u043c \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u043e\u043c \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e \u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0443 \u043f\u043e \u0442\u0430\u043a\u0438\u043c OpenSSL \u043c\u0435\u0442\u043e\u0434\u0430\u043c, \u043a\u0430\u043a \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, CMS_final, CMS_sign \u0438\u043b\u0438 CMS_ContentInfo_new. \u0410 \u0431\u0435\u0437 \u043d\u0438\u0445 \u0441\u043b\u043e\u0436\u043d\u043e \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u0442\u044c \u0441\u0435\u0431\u0435 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u0430\u043d\u0434\u0430\u0440\u0442\u043d\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b CMS \u043f\u043e\u0434\u043f\u0438\u0441\u0438. \u041f\u0440\u0438 \u044d\u0442\u043e\u043c \u0440\u0430\u0431\u043e\u0442\u0430 \u0441 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430\u043c\u0438 \u0447\u0430\u0441\u0442\u0438\u0447\u043d\u043e \u0432\u0435\u0434\u0435\u0442\u0441\u044f \u0447\u0435\u0440\u0435\u0437 OpenSSL.<\/p>\n<p>  <\/p>\n<p>\u042d\u0442\u043e \u0433\u043e\u0432\u043e\u0440\u0438\u0442 \u043e \u0442\u043e\u043c, \u0447\u0442\u043e \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0439 \u043a\u043b\u044e\u0447 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0438\u0437 mono \u0438 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u0432 EVP_PKEY \u0447\u0435\u0440\u0435\u0437 pem. \u0412 \u0441\u0438\u043b\u0443 \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u0441\u043d\u043e\u0432\u0430 \u043f\u043e\u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043a\u043b\u0430\u0441\u0441 \u043d\u0430\u0441\u043b\u0435\u0434\u043d\u0438\u043a \u043e\u0442 X509Certificate, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u044c \u0432\u0441\u0435 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438.<\/p>\n<p>  <\/p>\n<p>\u0412\u043e\u0442 \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u043e\u043f\u044b\u0442\u043a\u0438 \u043a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u041a\u0440\u0438\u043f\u0442\u043e\u041f\u0440\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u043d\u043e\u0432\u044b\u0439 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 \u043e\u0442 Handle \u2014 \u0442\u043e\u0436\u0435 \u043d\u0435 \u043f\u0440\u0438\u0432\u043e\u0434\u044f\u0442 \u043a \u0443\u0441\u043f\u0435\u0445\u0443 (mono \u043f\u0430\u0434\u0430\u0435\u0442 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439), \u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u043d\u0430 \u0431\u0430\u0437\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u0442 \u043a \u0443\u0442\u0435\u0447\u043a\u0430\u043c \u043f\u0430\u043c\u044f\u0442\u0438. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0435\u0434\u0438\u043d\u0441\u0442\u0432\u0435\u043d\u043d\u044b\u043c \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u043e\u043c \u043e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u0435 \u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 \u043d\u0430 \u0431\u0430\u0437\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0431\u0430\u0439\u0442 \u0441\u043e\u0434\u0435\u0440\u0436\u0430\u0449\u0435\u0433\u043e pem. PEM \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \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\">\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 PEM \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\u043b\u0443\u0447\u0438\u0442\u044c \u0444\u0430\u0439\u043b \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430&lt;\/summary&gt; * &lt;param name=\"_pCert\"&gt;\u0421\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442&lt;\/param&gt; * &lt;param name=\"_arData\"&gt;\u0412\u044b\u0445\u043e\u0434\u043d\u044b\u0435 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435&lt;\/param&gt; * &lt;param name=\"_fBase64\"&gt;\u0424\u043e\u0440\u043c\u0430\u0442 Base64&lt;\/param&gt; * &lt;param name=\"_sError\"&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; * **\/ public static int ToCerFile(this X509Certificate2 _pCert, out byte[] _arData,                              ref string _sError, bool _fBase64 = true) {     _arData = new byte[0];     try {         byte[] arData = _pCert.Export(X509ContentType.Cert);         \/\/ 0) DER         if (!_fBase64) {             _arData = arData;             return UConsts.S_OK;         }         \/\/ 1) Base64         using (TextWriter pWriter = new StringWriter()) {                                 pWriter.WriteLine(UCConsts.S_PEM_BEGIN_CERT);             pWriter.WriteLine(Convert.ToBase64String(arData, Base64FormattingOptions.InsertLineBreaks));             pWriter.WriteLine(UCConsts.S_PEM_END_CERT);             \/\/ 1.2) \u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c \u0438\u0442\u043e\u0433             _arData = Encoding.UTF8.GetBytes(pWriter.ToString());         }                         return UConsts.S_OK;     } catch (Exception E) {          _sError = UCConsts.S_TO_PEM_ERR.Frm(E.Message);          return UConsts.E_GEN_EXCEPTION;     }             } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0421\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u0431\u0435\u0437 \u0437\u0430\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0438 \u043c\u044b \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u0435\u0433\u043e \u0441\u0430\u043c\u043e\u0441\u0442\u043e\u044f\u0442\u0435\u043b\u044c\u043d\u043e, \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u0435 \u043f\u043e\u043b\u0435 \u0434\u043b\u044f \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 ENV_PKEY:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0424\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 ENV_PKEY \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 PEM \u0437\u0430\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">\/**&lt;summary&gt;\u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c OpenSSL \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0437\u0430\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 (EVP_PKEY) \u043f\u043e \u0434\u0430\u043d\u043d\u044b\u043c \u0437\u0430\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430&lt;\/summary&gt; * &lt;remarks&gt;\u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0443 \u0437\u0430\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0432 PEM&lt;\/remarks&gt; * &lt;param name=\"_arData\"&gt;\u0414\u0430\u043d\u043d\u044b\u0435 \u0437\u0430\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430&lt;\/param&gt; * &lt;returns&gt;\u041a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0437\u0430\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 (EVP_PKEY)&lt;\/returns&gt; * **\/ internal static IntPtr GetENV_PKEYOS(byte[] _arData) {     IntPtr hBIOPem = IntPtr.Zero;     try {         \/\/ 0)  \u0412\u044b\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0432 BIO         hBIOPem = UOpenSSLAPI.BIO_new_mem_buf( _arData, _arData.Length);         if (hBIOPem == IntPtr.Zero) return IntPtr.Zero;         IntPtr hKey = IntPtr.Zero;         \/\/ 1)  \u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u0437\u0430\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430         UOpenSSLAPI.PEM_read_bio_PrivateKey(hBIOPem, ref hKey, IntPtr.Zero, 0);         return hKey;     } finally {         if(hBIOPem != IntPtr.Zero) UOpenSSLAPI.BIO_free(hBIOPem);     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0412\u044b\u0433\u0440\u0443\u0437\u043a\u0430 \u0437\u0430\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0432 PEM, \u0437\u0430\u0434\u0430\u0447\u0430 \u0437\u043d\u0430\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043b\u043e\u0436\u043d\u0435\u0435, \u0447\u0435\u043c PEM \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430, \u043d\u043e \u043e\u043d\u0430 \u0443\u0436\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0430 <a href=\"https:\/\/gist.github.com\/therightstuff\/aa65356e95f8d0aae888e9f61aa29414\">\u0437\u0434\u0435\u0441\u044c<\/a>. \u041e\u0442\u043c\u0435\u0442\u0438\u043c, \u0447\u0442\u043e \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0430 \u0437\u0430\u043a\u0440\u044b\u0442\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0434\u0435\u043b\u043e \u00ab\u043a\u0440\u0430\u0439\u043d\u0435 \u043d\u0435\u0431\u0435\u0437\u043e\u043f\u0430\u0441\u043d\u043e\u0435\u00bb, \u0438 \u044d\u0442\u043e\u0433\u043e \u0441\u043b\u0435\u0434\u0443\u0435\u0442 \u0432\u0441\u044f\u0447\u0435\u0441\u043a\u0438 \u0438\u0437\u0431\u0435\u0433\u0430\u0442\u044c. \u0418 \u0442.\u00a0\u043a. \u0434\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 OpenSSL \u0442\u0430\u043a\u0430\u044f \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e\u0439, \u0442\u043e \u0432 Windows \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044e \u044d\u0442\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u043b\u0443\u0447\u0448\u0435 \u043f\u0440\u0435\u0434\u043f\u043e\u0447\u0442\u0438 \u043c\u0435\u0442\u043e\u0434\u044b crypt32.dll \u0438\u043b\u0438 \u0436\u0435 \u0448\u0442\u0430\u0442\u043d\u044b\u0435 \u043a\u043b\u0430\u0441\u0441\u044b .Net. \u0412 Linux \u0436\u0435 \u043f\u043e\u043a\u0430 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0440\u0430\u0431\u043e\u0442\u0430\u0442\u044c \u0442\u0430\u043a.<\/p>\n<p>  <\/p>\n<p>\u0422\u0430\u043a \u0436\u0435 \u0441\u0442\u043e\u0438\u0442 \u043f\u043e\u043c\u043d\u0438\u0442\u044c, \u0447\u0442\u043e \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u0441\u0441\u044b\u043b\u043a\u0438 \u0443\u043a\u0430\u0437\u044b\u0432\u0430\u044e\u0442 \u043d\u0430 \u043d\u0435\u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u0443\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u0438 \u0438 \u0438\u0445 \u043d\u0430\u0434\u043e \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0430\u0442\u044c. \u0422.\u043a. \u0432 .Net 4.5 X509Certificate2 \u043d\u0435 Disposable, \u0442\u043e \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043d\u0430\u0434\u043e \u0432 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440\u0435<\/p>\n<p>  <\/p>\n<h2>\u041f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0438\u0435<\/h2>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0438\u044f OpenSSL \u043c\u043e\u0436\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0443\u043f\u0440\u043e\u0449\u0435\u043d\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434 CMS_sign, \u043e\u0434\u043d\u0430\u043a\u043e \u043e\u043d \u0432 \u0432\u044b\u0431\u043e\u0440\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u043e\u043f\u0438\u0440\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043a\u043e\u043d\u0444\u0438\u0433\u0443\u0440\u0430\u0446\u0438\u043e\u043d\u043d\u044b\u0439 \u0444\u0430\u0439\u043b, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u0443\u0434\u0435\u0442 \u043e\u0434\u0438\u043d \u0434\u043b\u044f \u0432\u0441\u0435\u0445 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043b\u0443\u0447\u0448\u0435 \u043e\u043f\u0438\u0440\u0430\u044f\u0441\u044c \u043d\u0430 <a href=\"https:\/\/github.com\/openssl\/openssl\/blob\/master\/crypto\/cms\/cms_smime.c#L435\">\u043a\u043e\u0434 <\/a>\u044d\u0442\u043e\u0433\u043e \u043c\u0435\u0442\u043e\u0434\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u0442\u044c \u0430\u043d\u0430\u043b\u043e\u0433\u0438\u0447\u043d\u043e\u0435 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u0438:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u0434\u043f\u0438\u0441\u044c \u0434\u0430\u043d\u043d\u044b\u0445<\/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=\"_arData\"&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=\"_pCert\"&gt;\u0421\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442&lt;\/param&gt; * &lt;param name=\"_sError\"&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=\"_arRes\"&gt;\u041f\u043e\u0434\u043f\u0438\u0441\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; * **\/ internal static int SignDataOS(byte[] _arData, X509Certificate2 _pCert, out byte[] _arRes, ref string _sError) {      _arRes         = new byte[0];     uint iFlags    = UCConsts.CMS_DETACHED;     IntPtr hData   = IntPtr.Zero;     IntPtr hBIORes = IntPtr.Zero;     IntPtr hCMS    = IntPtr.Zero;     try {         \/\/ 0) \u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0441\u0435\u0440\u0442\u0444\u0438\u0438\u043a\u0430\u0442         ISDP_X509Cert pCert = ISDP_X509Cert.Convert(_pCert, TCryptoPath.cpOpenSSL);         \/\/ 1) \u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c BIO \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438         int iRes = GetBIOByBytesOS(_arData, out hData, ref _sError);         if (iRes != UConsts.S_OK) return iRes;         \/\/ 2) \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0438\u0442\u043e\u0433\u043e\u0432\u044b\u0439 BIO         hBIORes = UOpenSSLAPI.BIO_new(UOpenSSLAPI.BIO_s_mem());         \/\/ 3) \u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u043e\u0431\u044a\u0435\u043a\u0442 \u043f\u043e\u0434\u043f\u0438\u0441\u0438         hCMS = UOpenSSLAPI.CMS_ContentInfo_new();         if (hCMS == IntPtr.Zero) return RetErrOS(ref _sError, UCConsts.S_OS_CMS_CR_ERR);         if (!UOpenSSLAPI.CMS_SignedData_init(hCMS))              return RetErrOS(ref _sError, UCConsts.S_OS_CMS_INIT_ERR);         \/\/ 4) \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u0430         if(UOpenSSLAPI.CMS_add1_signer(hCMS, pCert.hRealHandle, pCert.hOSKey,                                        pCert.hOSDigestAlg, iFlags) == IntPtr.Zero)             return RetErrOS(ref _sError, UCConsts.S_OS_CMS_SET_SIGNER_ERR);         \/\/ 5) \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0444\u043b\u0430\u0433\u0430 - \u043e\u0442\u0446\u0435\u043f\u043b\u0435\u043d\u043d\u0430\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u044c         if (!UOpenSSLAPI.CMS_set_detached(hCMS, 1))             return RetErrOS(ref _sError, UCConsts.S_OS_CMS_SET_DET_ERR);         \/\/ 6) \u0417\u0430\u0432\u0435\u0440\u0448\u0435\u043d\u0438\u0435 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u0438         if (!UOpenSSLAPI.CMS_final(hCMS, hData, IntPtr.Zero, iFlags))             return RetErrOS(ref _sError, UCConsts.S_OS_CMS_FINAL_ERR);         \/\/ 7) \u041f\u0435\u0440\u0435\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u043c \u0432 \u0437\u0430\u0433\u043e\u0442\u043e\u0432\u043b\u0435\u043d\u043d\u044b\u0439 BIO         if (!UOpenSSLAPI.i2d_CMS_bio_stream(hBIORes, hCMS, IntPtr.Zero, iFlags))               return RetErrOS(ref _sError, UCConsts.S_OS_CMS_EXP_TO_BIO_ERR);         \/\/ 8) \u0421\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 BIO         return ReadFromBIO_OS(hBIORes, out _arRes, ref _sError);     } catch (Exception E) {         _sError = UCConsts.S_SIGN_OS_GEN_ERR.Frm(E.Message);         return UConsts.E_GEN_EXCEPTION;     } finally {         if(hBIORes != IntPtr.Zero) UOpenSSLAPI.BIO_free(hBIORes);         if(hData != IntPtr.Zero) UOpenSSLAPI.BIO_free(hData);         if(hCMS != IntPtr.Zero) UOpenSSLAPI.CMS_ContentInfo_free(hCMS);     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0425\u043e\u0434 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u0439. \u0421\u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u0435\u043c \u0432\u0445\u043e\u0434\u044f\u0449\u0438\u0439 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 (\u0435\u0441\u043b\u0438 \u043e\u043d \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f X509Certificate2) \u0432 \u043d\u0430\u0448 \u0442\u0438\u043f. \u0422.\u043a. \u043c\u044b \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u043c \u0441\u043e \u0441\u0441\u044b\u043b\u043a\u0430\u043c\u0438 \u043d\u0430 \u043d\u0435\u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u0443\u044e \u043e\u0431\u043b\u0430\u0441\u0442\u044c \u043f\u0430\u043c\u044f\u0442\u0438, \u0442\u043e \u0437\u0430 \u043d\u0438\u043c\u0438 \u043d\u0430\u0434\u043e \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0441\u043b\u0435\u0434\u0438\u0442\u044c. .Net \u0447\u0435\u0440\u0435\u0437 \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u0432\u0440\u0435\u043c\u044f \u043f\u043e\u0441\u043b\u0435 \u0432\u044b\u0445\u043e\u0434\u0430 \u0441\u0441\u044b\u043b\u043a\u0438 \u043d\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 \u0438\u0437 \u043e\u0431\u043b\u0430\u0441\u0442\u0438 \u0432\u0438\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0441\u0430\u043c \u0437\u0430\u043f\u0443\u0441\u0442\u0438\u0442 \u0434\u0435\u0441\u0442\u0440\u0443\u043a\u0442\u043e\u0440. \u0410 \u0432 \u043d\u0435\u043c \u043c\u044b \u0443\u0436\u0435 \u0442\u043e\u0447\u043d\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u043b\u0438 \u043c\u0435\u0442\u043e\u0434\u044b, \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0434\u043b\u044f \u043e\u0447\u0438\u0441\u0442\u043a\u0438 \u0432\u0441\u0435\u0439 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0439 \u0441 \u043d\u0438\u043c \u043d\u0435\u0443\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c\u043e\u0439 \u043f\u0430\u043c\u044f\u0442\u0438. \u0422\u0430\u043a\u043e\u0439 \u043f\u043e\u0434\u0445\u043e\u0434 \u043f\u043e\u0437\u0432\u043e\u043b\u0438\u0442 \u043d\u0430\u043c \u043d\u0435 \u0442\u0440\u0430\u0442\u0438\u0442\u044c \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u043e\u0442\u0441\u043b\u0435\u0436\u0438\u0432\u0430\u043d\u0438\u044f \u044d\u0442\u0438\u0445 \u0441\u0441\u044b\u043b\u043e\u043a \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432\u043d\u0443\u0442\u0440\u0438 \u043c\u0435\u0442\u043e\u0434\u0430. <\/p>\n<p>  <\/p>\n<p>\u0420\u0430\u0437\u043e\u0431\u0440\u0430\u0432\u0448\u0438\u0441\u044c \u0441 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u043c \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c BIO \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 \u043f\u043e\u0434\u043f\u0438\u0441\u0438. \u0417\u0430\u0442\u0435\u043c \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u0430, \u0441\u0442\u0430\u0432\u0438\u043c \u0444\u043b\u0430\u0433 \u043e\u0442\u0446\u0435\u043f\u043b\u0435\u043d\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u0438 \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0444\u0438\u043d\u0430\u043b\u044c\u043d\u043e\u0435 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u0438. \u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u043c \u0432 BIO. \u041e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0438\u0437 BIO \u043c\u0430\u0441\u0441\u0438\u0432 \u0431\u0430\u0439\u0442. \u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 BIO \u0432 \u043d\u0430\u0431\u043e\u0440 \u0431\u0430\u0439\u0442 \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442\u0441\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043b\u0443\u0447\u0448\u0435 \u0432\u044b\u043d\u0435\u0441\u0442\u0438 \u0438\u0445 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434\u044b:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">BIO \u0432 byte[] \u0438 \u043e\u0431\u0440\u0430\u0442\u043d\u043e<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">\/**&lt;summary&gt;\u041f\u0440\u043e\u0447\u0438\u0442\u0430\u0442\u044c \u0438\u0437 BIO \u043c\u0430\u0441\u0441\u0438\u0432 \u0431\u0430\u0439\u0442 \u0438\u0437 OpenSSL&lt;\/summary&gt; * &lt;param name=\"_hBIO\"&gt;\u041a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 BIO&lt;\/param&gt; * &lt;param name=\"_sError\"&gt;\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0430\u044f \u0441\u0442\u0440\u043a\u043e\u0430 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439&lt;\/param&gt; * &lt;param name=\"_arRes\"&gt;\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442&lt;\/param&gt; * &lt;param name=\"_iLen\"&gt;\u0414\u043b\u0438\u043d\u0430 \u0434\u0430\u043d\u043d\u044b\u0445, \u0435\u0441\u043b\u0438 0 - \u0442\u043e \u0432\u0441\u0435 \u0447\u0442\u043e \u0435\u0441\u0442\u044c&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; * **\/ internal static int ReadFromBIO_OS(IntPtr _hBIO, out byte[] _arRes, ref string _sError, uint _iLen = 0) {     _arRes = new byte[0];     IntPtr hRes = IntPtr.Zero;     uint iLen = _iLen;     if(iLen == 0) iLen = int.MaxValue;     try {         \/\/ 0) \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u043c \u0434\u043b\u0438\u043d\u0443         iLen = UOpenSSLAPI.BIO_read(_hBIO, IntPtr.Zero, int.MaxValue);         \/\/ 1) \u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0431\u0443\u0444\u0435\u0440 \u0438 \u0447\u0438\u0442\u0430\u0435\u043c  \u043d\u0435\u0433\u043e          hRes  = Marshal.AllocHGlobal((int)iLen);         if (UOpenSSLAPI.BIO_read(_hBIO, hRes, iLen) != iLen) {             _sError = UCConsts.S_OS_BIO_READ_LEN_ERR;             return UConsts.E_CRYPTO_ERR;         }          \/\/ 2) \u0418\u0442\u043e\u0433\u043e\u0432\u044b\u0439 \u043c\u0430\u0441\u0441\u0438\u0432         _arRes = new byte[iLen];         Marshal.Copy(hRes, _arRes, 0, _arRes.Length);         return UConsts.S_OK;;     } catch (Exception E) {         _sError = UCConsts.S_OS_BIO_READ_GEN_ERR.Frm(E.Message);         return UConsts.E_GEN_EXCEPTION;     } finally {          if(hRes != IntPtr.Zero) Marshal.FreeHGlobal(hRes);     } } \/**&lt;summary&gt;\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c BIO \u043f\u043e \u043d\u0430\u0431\u043e\u0440\u0443 \u0431\u0430\u0439\u0442&lt;\/summary&gt; * &lt;param name=\"_arData\"&gt;\u0414\u0430\u043d\u043d\u044b\u0435&lt;\/param&gt; * &lt;param name=\"_hBIO\"&gt;\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 BIO&lt;\/param&gt; * &lt;param name=\"_sError\"&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 GetBIOByBytesOS(byte[] _arData, out IntPtr _hBIO, ref string _sError) {     _hBIO = UOpenSSLAPI.BIO_new_mem_buf( _arData, _arData.Length);     if (_hBIO == IntPtr.Zero)          return  RetErrOS(ref _sError, UCConsts.S_OS_CM_BIO_CR_ERR);     return UConsts.S_OK; } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0422\u0430\u043a \u0436\u0435 \u043a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u041a\u0440\u0438\u043f\u0442\u043e\u041f\u0440\u043e \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0438\u0437 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0435 \u0445\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u0438. \u041d\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 OpenSSL \u043e\u043d \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u043f\u0440\u044f\u043c\u043e \u0432 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0435:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \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;\u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0430 \u0445\u044d\u0448\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0438\u0437 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442\u0430 \u0441\u0435\u0440\u0442\u0444\u0438\u0438\u043a\u0430\u0442\u0430 OpenSSL&lt;\/summary&gt; * &lt;param name=\"_hCert\"&gt;\u041a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0442\u0430 (X509)&lt;\/param&gt; * &lt;returns&gt;\u041a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0430\u0433\u043b\u043e\u0440\u0438\u0442\u043c\u0430&lt;\/returns&gt; * **\/ public static IntPtr GetDigestAlgOS(IntPtr _hCert) {     x509_st pCert = (x509_st)Marshal.PtrToStructure(_hCert, typeof(x509_st));     X509_algor_st pAlgInfo = (X509_algor_st)Marshal.PtrToStructure(pCert.sig_alg, typeof(X509_algor_st));     IntPtr hAlgSn = UOpenSSLAPI.OBJ_nid2sn(UOpenSSLAPI.OBJ_obj2nid(pAlgInfo.algorithm));     return UOpenSSLAPI.EVP_get_digestbyname(hAlgSn); } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0421\u043f\u043e\u0441\u043e\u0431 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0441\u044f \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0445\u0438\u0442\u0440\u044b\u0439, \u043d\u043e \u043e\u043d \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442. \u0412 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430\u0446\u0438\u0438 1.0.2 \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u043c\u0435\u0442\u043e\u0434 <a href=\"https:\/\/www.openssl.org\/docs\/man1.0.2\/crypto\/EVP_get_digestbynid.html\">EVP_get_digestbynid<\/a>, \u043e\u0434\u043d\u0430\u043a\u043e \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u043e\u0439 \u043d\u0430\u043c\u0438 \u0432\u0435\u0440\u0441\u0438\u0438 \u0435\u0433\u043e \u043d\u0435 \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0442. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c nid, \u0430 \u043d\u0430 \u0435\u0433\u043e \u043e\u0441\u043d\u043e\u0432\u0435 \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u0435 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u0435. \u0418 \u0443\u0436\u0435 \u043f\u043e \u043a\u043e\u0440\u043e\u0442\u043a\u043e\u043c\u0443 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044e \u043c\u043e\u0436\u043d\u043e \u0438\u0437\u0432\u043b\u0435\u0447\u044c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c \u0448\u0442\u0430\u0442\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e \u0438\u043c\u0435\u043d\u0438.<\/p>\n<p>  <\/p>\n<h2>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u0438<\/h2>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u0430\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u044c \u043d\u0443\u0436\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0435. OpenSSL \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043f\u043e\u0434\u043f\u0438\u0441\u044c \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\">\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;\u041f\u0440\u043e\u0432\u0435\u0440\u044f\u0435\u0442 \u043f\u043e\u0434\u043f\u0438\u0441\u044c&lt;\/summary&gt; * &lt;param name=\"_arData\"&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=\"_arSign\"&gt;\u043f\u043e\u0434\u043f\u0438\u0441\u044c&lt;\/param&gt; * &lt;param name=\"_pCert\"&gt;\u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442&lt;\/param&gt; * &lt;param name=\"_sError\"&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=\"_pLocation\"&gt;\u041c\u0435\u0441\u0442\u043e\u043f\u043b\u043e\u0436\u0435\u043d\u0438\u0435&lt;\/param&gt; * &lt;param name=\"_fVerifyOnlySign\"&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;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; * **\/ internal static int CheckSignOS(byte[] _arData, byte[] _arSign, out X509Certificate2 _pCert, ref string _sError,                                 bool _fVerifyOnlySign = true,                                  StoreLocation _pLocation = StoreLocation.CurrentUser){     _pCert = null;     IntPtr hBIOData = IntPtr.Zero;     IntPtr hCMS     = IntPtr.Zero;     IntPtr hTrStore = IntPtr.Zero;     try {         \/\/ 0) \u0424\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 BIO \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u0438         int iRes = GetBIOByBytesOS(_arData, out hBIOData, ref _sError);         if (iRes != UConsts.S_OK) return iRes;         \/\/ 1) \u0427\u0442\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b CMS         iRes = GetCMSFromBytesOS(_arSign, out hCMS, ref _sError);         if (iRes != UConsts.S_OK) return iRes;         uint iFlag =  UCConsts.CMS_DETACHED;                         \/\/ 2) \u0424\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0433\u043e \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430         if (!_fVerifyOnlySign) {             iRes = GetTrustStoreOS(_pLocation, out hTrStore, ref _sError);             if (iRes != UConsts.S_OK) return iRes;         } else              iFlag |= UCConsts.CMS_NO_SIGNER_CERT_VERIFY;         \/\/ 3) \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u0438         if (!UOpenSSLAPI.CMS_verify(hCMS, IntPtr.Zero, hTrStore, hBIOData, IntPtr.Zero, iFlag))              return RetErrOS(ref _sError, UCConsts.S_OS_CM_CHECK_ERR);         return UConsts.S_OK;                      } finally {         if(hBIOData != IntPtr.Zero) UOpenSSLAPI.BIO_free(hBIOData);         if(hCMS != IntPtr.Zero) UOpenSSLAPI.CMS_ContentInfo_free(hCMS);         if(hTrStore != IntPtr.Zero) UOpenSSLAPI.X509_STORE_free(hTrStore);     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0412\u043d\u0430\u0447\u0430\u043b\u0435 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0434\u043f\u0438\u0441\u0438 \u0438\u0437 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0431\u0430\u0439\u0442 \u0432 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 CMS:   <\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0424\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b CMS<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">\/**&lt;summary&gt;\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c CMS \u0438\u0437 \u043d\u0430\u0431\u043e\u0440\u0430 \u0431\u0430\u0439\u0442&lt;\/summary&gt; * &lt;param name=\"_arData\"&gt;\u0414\u0430\u043d\u043d\u044b\u0435 CMS&lt;\/param&gt; * &lt;param name=\"_hCMS\"&gt;\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c  \u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 CMS&lt;\/param&gt; * &lt;param name=\"_sError\"&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 GetCMSFromBytesOS(byte[] _arData, out IntPtr _hCMS, ref string _sError) {     _hCMS          = IntPtr.Zero;      IntPtr hBIOCMS = IntPtr.Zero;     IntPtr hCMS    = IntPtr.Zero;     try {         \/\/ 0) \u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0430\u0446\u0437\u0438\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b CMS         hCMS = UOpenSSLAPI.CMS_ContentInfo_new();         if (hCMS == IntPtr.Zero) return RetErrOS(ref _sError);         if (!UOpenSSLAPI.CMS_SignedData_init(hCMS))             return RetErrOS(ref _sError);         \/\/ 1) \u0427\u0442\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 BIO         hBIOCMS = UOpenSSLAPI.BIO_new_mem_buf(_arData, _arData.Length);         if (hBIOCMS == IntPtr.Zero) return RetErrOS(ref _sError);         \/\/ 2) \u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 CMS         if (UOpenSSLAPI.d2i_CMS_bio(hBIOCMS, ref hCMS) == IntPtr.Zero)             return RetErrOS(ref _sError);         \/\/ 3) \u0412\u0441\u0435 \u043e\u043a - \u043f\u0435\u0440\u0435\u043a\u0440\u044b\u0432\u0430\u0435\u043c, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0437\u0430\u043d\u0443\u043b\u0438\u043b\u043e         _hCMS = hCMS;         hCMS = IntPtr.Zero;         return UConsts.S_OK;     } finally {         if(hBIOCMS != IntPtr.Zero) UOpenSSLAPI.BIO_free(hBIOCMS);         if(hCMS != IntPtr.Zero) UOpenSSLAPI.CMS_ContentInfo_free(hCMS);     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0422\u0430\u043a \u0436\u0435 \u0437\u0430\u0433\u0440\u0443\u0436\u0430\u044e\u0442\u0441\u044f \u0434\u0430\u043d\u043d\u044b\u0435 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u0430, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0431\u044b\u043b \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d \u0432 BIO. \u0415\u0441\u043b\u0438 \u0442\u0440\u0435\u0431\u0443\u0435\u0442\u0441\u044f \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442, \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u043f\u043e\u0434\u043f\u0438\u0441\u044c \u0431\u044b\u043b\u0430 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0430, \u0442\u043e \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0434\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u0445 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 (\u043a\u043e\u0440\u043d\u0435\u0432\u044b\u0445 \u0438 \u043f\u0440\u043e\u043c\u0435\u0436\u0443\u0442\u043e\u0447\u043d\u044b\u0445) \u043d\u0430 \u0431\u0430\u0437\u0435 \u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0431\u0443\u0434\u0435\u0442 \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0446\u0435\u043f\u043e\u0447\u043a\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 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\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 \u0434\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u043e\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0432 \u043f\u0430\u043c\u044f\u0442\u0438&lt;\/summary&gt; * &lt;param name=\"_hStore\"&gt;\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0430\u044f \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435&lt;\/param&gt; * &lt;param name=\"_pLocation\"&gt;\u041c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430&lt;\/param&gt; * &lt;param name=\"_sError\"&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 GetTrustStoreOS(StoreLocation _pLocation, out IntPtr _hStore, ref string _sError) {     _hStore = IntPtr.Zero;     IntPtr hStore   = IntPtr.Zero;     try {         List&lt;X509Certificate2&gt; pCerts = GetCertList(_pLocation, StoreName.Root, TCryptoPath.cpOpenSSL);         pCerts.AddRange(GetCertList(_pLocation, StoreName.AuthRoot, TCryptoPath.cpOpenSSL));         \/\/ 1) \u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435         hStore = UOpenSSLAPI.X509_STORE_new();         foreach (X509Certificate2 pCert in pCerts) {             \/\/ \u0414\u0430\u0436\u0435 \u0435\u0441\u043b\u0438 \u043e\u0448\u0438\u0431\u043a\u0430 \u0438\u0434\u0435\u043c \u0434\u0430\u043b\u044c\u0448\u0435 (\u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u043e\u0448\u0438\u0431\u043a\u0430 \u0434\u0443\u0431\u043b\u044f \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432)             UOpenSSLAPI.X509_STORE_add_cert(hStore, pCert.getRealHandle());         }         \/\/ 2) \u041e\u0447\u0438\u0441\u0442\u043a\u0430 \u043e\u0448\u0438\u0431\u043e\u043a         UOpenSSLAPI.ERR_clear_error();         _hStore = hStore;         hStore = IntPtr.Zero;         return UConsts.S_OK;     } catch (Exception E) {         _sError = UCConsts.S_FORM_TRUST_STORE_ERR.Frm(E.Message);         return UConsts.E_GEN_EXCEPTION;     } finally {         if (hStore != IntPtr.Zero) UOpenSSLAPI.X509_STORE_free(hStore); } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0415\u0441\u043b\u0438 \u0447\u0430\u0441\u0442\u044c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u0438\u0437 \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0432 \u043f\u043e\u0434\u043f\u0438\u0441\u0438, \u0442\u043e \u0438\u0445 \u0442\u0430\u043a \u0436\u0435 \u043d\u0430\u0434\u043e \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u0432 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 (\u0432 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0433\u043b\u0430\u0432\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u043e, \u043a\u0430\u043a \u0438\u0445 \u043e\u0442\u0442\u0443\u0434\u0430 \u0438\u0437\u0432\u043b\u0435\u0447\u044c). \u041d\u0430\u043a\u043e\u043d\u0435\u0446 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 CMS_Verify, \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0438 \u043e\u0441\u0443\u0449\u0435\u0441\u0442\u0432\u043b\u044f\u0435\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443.<\/p>\n<p>  <\/p>\n<p>\u0412 \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u0434\u043e\u043f\u043e\u043b\u043d\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0439 \u043d\u0430\u0441\u0442\u0440\u043e\u0439\u043a\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 (\u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u0440\u0438 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u0431\u0435\u0437 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u044f CRL), \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0432 \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0443\u044e \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 iFlag \u0434\u043e\u0431\u0430\u0432\u0438\u0442\u044c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0444\u043b\u0430\u0433\u0438.<\/p>\n<p>  <\/p>\n<h2>\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0438<\/h2>\n<p>  <\/p>\n<p>\u0412 \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 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0438 \u0432 \u0443\u0434\u043e\u0431\u043d\u043e\u043c \u0434\u043b\u044f \u043a\u043b\u0438\u0435\u043d\u0442\u043e\u0432 \u0432\u0438\u0434\u0435. \u0414\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0440\u0430\u0437\u043d\u044b\u0445 \u043c\u0435\u0441\u0442\u0430\u0445 \u043f\u043e \u0440\u0430\u0437\u043d\u043e\u043c\u0443, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c \u043a\u043b\u0430\u0441\u0441, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u0434\u0430\u043d\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u0431\u0443\u0434\u0435\u0442 \u0445\u0440\u0430\u043d\u0438\u0442\u0441\u044f \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. \u0412 .Net \u0442\u0430\u043a\u043e\u0439 \u043a\u043b\u0430\u0441\u0441 \u0435\u0441\u0442\u044c \u2014 SignedCms, \u043e\u0434\u043d\u0430\u043a\u043e \u043a\u0430\u043a \u0443\u0436\u0435 \u0431\u044b\u043b\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u043f\u0440\u043e \u041a\u0440\u0438\u043f\u0442\u043e\u041f\u0440\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0435\u0433\u043e \u043d\u0435 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c\u0441\u044f \u0438 \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u043f\u0438\u0441\u0430\u0442\u044c \u0441\u0432\u043e\u0439 \u0430\u043d\u0430\u043b\u043e\u0433. <\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u0434\u043f\u0438\u0441\u044c \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432 \u0441\u0435\u0431\u0435 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u0435 (\u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u043e\u0432 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e, \u043d\u043e \u0442\u0430\u043a \u0431\u044b\u0432\u0430\u0435\u0442 \u043e\u0447\u0435\u043d\u044c \u0440\u0435\u0434\u043a\u043e) \u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u0434\u043b\u044f \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0446\u0435\u043f\u043e\u0447\u043a\u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \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 \u2014 \u0432\u043d\u0430\u0447\u0430\u043b\u0435 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442\u0441\u044f \u043e\u0431\u0449\u0438\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432, \u0430 \u0437\u0430\u0442\u0435\u043c \u0441\u043f\u0438\u0441\u043e\u043a \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u043e\u0432. <\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0430\u0437\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0434\u043f\u0438\u0441\u0438<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">\/**&lt;summary&gt;\u0420\u0430\u0437\u0431\u043e\u0440 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u043e\u0434\u043f\u0438\u0441\u0438&lt;\/summary&gt; * &lt;param name=\"_arSign\"&gt;\u041f\u043e\u0434\u043f\u0438\u0441\u044c&lt;\/param&gt; * &lt;param name=\"_sError\"&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=\"_arContent\"&gt;\u0414\u0430\u043d\u043d\u044b\u0435 \u0434\u043b\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u0438&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 int DecodeOS(byte[] _arSign, byte[] _arContent, ref string _sError) {     IntPtr hBIOData = IntPtr.Zero;     IntPtr hCMS     = IntPtr.Zero;     IntPtr hCerts   = IntPtr.Zero;     try {         \/\/ 0) \u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u0421MS         int iRes = UCUtils.GetCMSFromBytesOS(_arSign, out hCMS, ref _sError);         if(iRes != UConsts.S_OK) return iRes;         iRes = UCUtils.GetBIOByBytesOS(_arContent, out hBIOData, ref _sError);         if(iRes != UConsts.S_OK) return iRes;         \/\/ 1) \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0444\u043b\u0430\u0433\u0438         uint iFlags = UCConsts.CMS_NO_SIGNER_CERT_VERIFY;         if(_arContent.Length == 0) iFlags |= UCConsts.CMS_NO_CONTENT_VERIFY;         \/\/ 2) \u0421\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c CMS         if (!UOpenSSLAPI.CMS_verify(hCMS, IntPtr.Zero, IntPtr.Zero, hBIOData, IntPtr.Zero,  iFlags))              return UCUtils.RetErrOS(ref _sError, UCConsts.S_OS_CMS_VERIFY_ERR);         \/\/ 3) \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u044b         hCerts = UOpenSSLAPI.CMS_get0_signers(hCMS);         int iCnt = UOpenSSLAPI.sk_num(hCerts);         for (int i = 0; i &lt; iCnt; i++) {             IntPtr hCert = UOpenSSLAPI.sk_value(hCerts, i);             byte[] arData;             iRes = UCUtils.GetCertBytesOS(hCert, out arData, ref _sError);             if(iRes != UConsts.S_OK) return iRes;             fpCertificates.Add(ISDP_X509Cert.Create(arData, TCryptoPath.cpOpenSSL));         }         \/\/ 4) \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u043e\u0432         IntPtr hSigners = UOpenSSLAPI.CMS_get0_SignerInfos(hCMS);                         iCnt = UOpenSSLAPI.sk_num(hSigners);                         for (int i = 0; i &lt; iCnt; i++) {             IntPtr hSignerInfo = UOpenSSLAPI.sk_value(hSigners, i);             \/\/ 4.1) \u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u0435             ISDPSignerInfo pInfo = new ISDPSignerInfo(this);             iRes = pInfo.DecodeOS(hSignerInfo, ref _sError);             if(iRes != UConsts.S_OK) return iRes;             fpSignerInfos.Add(pInfo);         }         return UConsts.S_OK;     } catch (Exception E) {         _sError = UCConsts.S_OS_CMS_DECODE.Frm(E.Message);         return UConsts.E_GEN_EXCEPTION;     } finally {         if(hCerts != IntPtr.Zero) UOpenSSLAPI.sk_free(hCerts);         if(hBIOData != IntPtr.Zero) UOpenSSLAPI.BIO_free(hBIOData);         if(hCMS != IntPtr.Zero) UOpenSSLAPI.CMS_ContentInfo_free(hCMS);     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0438 \u0432 \u043f\u0440\u043e\u0448\u043b\u043e\u0439 \u0433\u043b\u0430\u0432\u0435, \u0441\u043d\u0430\u0447\u0430\u043b\u0430 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0438\u0437 \u043c\u0430\u0441\u0441\u0438\u0432\u043e\u0432 \u0431\u0430\u0439\u0442 BIO \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u043f\u043e\u0434\u043f\u0438\u0441\u0438 (\u0435\u0441\u043b\u0438 \u043d\u0443\u0436\u043d\u043e) \u0438 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 CMS, \u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0443. \u042d\u0442\u043e \u043c\u043e\u0436\u0435\u0442 \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c\u0441\u044f \u0441\u0442\u0440\u0430\u043d\u043d\u044b\u043c, \u043d\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0438 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u0432 \u043c\u0435\u0442\u043e\u0434\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u2014 \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0435\u0440\u0435\u0434 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0443\u0436\u043d\u043e \u0432\u044b\u0437\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0442 \u043c\u0435\u0442\u043e\u0434.<\/p>\n<p>  <\/p>\n<p>\u0421\u043f\u0438\u0441\u043e\u043a \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u0438 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u043e\u0432 \u0432\u044b\u0434\u0430\u0435\u0442\u0441\u044f \u0432 \u0432\u0438\u0434\u0435 \u0441\u0442\u0435\u043a\u043e\u0432 (STACK_OF(X509)), \u043e\u0434\u043d\u0430\u043a\u043e \u0435\u0441\u043b\u0438 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u044d\u043b\u0435\u043c\u0435\u043d\u0442\u044b \u043c\u0435\u0442\u043e\u0434\u043e\u043c sk_pop, \u0442\u043e \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u043d\u044b\u0445 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440 \u0431\u0443\u0434\u0435\u0442 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u0447\u0438\u043a\u0430. \u0415\u0441\u043b\u0438 \u0436\u0435\u043b\u0430\u043d\u0438\u044f \u0434\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e\u0433\u043e \u043d\u0435\u0442, \u0442\u043e \u0441\u0442\u043e\u0438\u0442 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u0432 \u0446\u0438\u043a\u043b\u0435 \u0438 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0442\u044c \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u043c sk_value.<\/p>\n<p>  <\/p>\n<p>\u0421\u0442\u043e\u0438\u0442 \u043e\u0442\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u043f\u0440\u0438 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0438 \u0441\u043f\u0438\u0441\u043a\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043c\u0435\u0442\u043e\u0434 CMS_get0_signers \u0432\u043c\u0435\u0441\u0442\u043e CMS_get1_certs. \u041f\u0435\u0440\u0432\u044b\u0439 \u0432\u044b\u0434\u0430\u0435\u0442 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u043e\u0432, \u0432\u0442\u043e\u0440\u043e\u0439 \u0432\u0441\u0435 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u044b. \u041f\u043e \u043b\u043e\u0433\u0438\u043a\u0435 \u043f\u0440\u0430\u0432\u0438\u043b\u044c\u043d\u0435\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0442\u043e\u0440\u043e\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442, \u043d\u043e \u043e\u043d \u0441\u043e\u0434\u0435\u0440\u0436\u0438\u0442 \u0432\u044b\u0437\u043e\u0432 \u043c\u0435\u0442\u043e\u0434\u0430 \u043f\u043e\u0442\u043e\u043a\u043e\u0432\u043e\u0439 \u0431\u043b\u043e\u043a\u0438\u0440\u043e\u0432\u043a\u0438, \u0447\u0442\u043e \u0432 \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442\u0435 \u043f\u043e\u0434 \u043d\u0430\u0433\u0440\u0443\u0437\u043a\u043e\u0439 \u0432\u0435\u0434\u0435\u0442 \u043a \u0443\u0442\u0435\u0447\u043a\u0430\u043c \u043f\u0430\u043c\u044f\u0442\u0438:<\/p>\n<p>  <\/p>\n<pre><code>CRYPTO_add(&amp;cch-&gt;d.certificate-&gt;references, 1, CRYPTO_LOCK_X509); <\/code><\/pre>\n<p>  <\/p>\n<p>\u0412 \u0432\u0435\u0440\u0441\u0438\u0438 <a href=\"https:\/\/github.com\/openssl\/openssl\/blob\/32f803d88ec3df7f95dfbf840c271f7438ce3357\/crypto\/cms\/cms_lib.c#L499\">1.1.0<\/a> \u0432\u044b\u0437\u043e\u0432 \u0437\u0430\u043c\u0435\u043d\u0435\u043d \u043d\u0430 X509_up_ref, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0431\u043b\u0435\u043c\u0430 \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u0443\u0436\u0435 \u0443\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0430.<br \/>  \u0414\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043a\u0430\u0436\u0434\u043e\u043c \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u0435 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0420\u0430\u0441\u043f\u0430\u0440\u0441\u0438\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \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 \u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u0435&lt;\/summary&gt; * &lt;param name=\"_hSignerInfo\"&gt;Handler \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u0435 (OpenSSL)&lt;\/param&gt; * &lt;param name=\"_sError\"&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 DecodeOS(IntPtr _hSignerInfo, ref string _sError) {     try {         \/\/ 0) \u041e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u0438\u0435 \u0441\u0435\u0440\u0442\u0444\u0438\u043a\u0430\u0442\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u0430         int iRes = UCUtils.GetSignerInfoCertOS(_hSignerInfo, fpSignedCMS.pCertificates,                                                 out fpCertificate, ref _sError);         if(iRes != UConsts.S_OK) return iRes;         \/\/ 1) \u0418\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u0442\u044b \u043f\u043e\u0434\u043f\u0438\u0441\u0438         uint iPos =  UOpenSSLAPI.CMS_signed_get_attr_by_NID(_hSignerInfo, UCConsts.NID_pkcs9_signingTime, 0);         IntPtr hAttr = UOpenSSLAPI.CMS_signed_get_attr(_hSignerInfo, iPos);         IntPtr hDateTime = UOpenSSLAPI.X509_ATTRIBUTE_get0_data(hAttr, 0, UCConsts.V_ASN1_UTCTIME, IntPtr.Zero);         asn1_string_st pDate = (asn1_string_st)Marshal.PtrToStructure(hDateTime, typeof(asn1_string_st));         \/\/ 2) \u041f\u0440\u0435\u043e\u0431\u0440\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 Pkcs9SigningTime         byte[] arDateAttr = new byte[pDate.iLength];         Marshal.Copy(pDate.hData, arDateAttr, 0, (int)pDate.iLength);         arDateAttr = new byte[] { (byte)UCConsts.V_ASN1_UTCTIME, (byte)pDate.iLength}.Concat(arDateAttr).ToArray();         fpSignedAttributes.Add(new Pkcs9SigningTime(arDateAttr));         return UConsts.S_OK;     } catch (Exception E) {         _sError = UCConsts.S_CMS_SIGNER_DEC_OS_ER.Frm(E.Message);         return UConsts.E_GEN_EXCEPTION;     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0412 \u043d\u0435\u043c, \u0432\u043d\u0430\u0447\u0430\u043b\u0435 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u043c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u0430, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0434\u0430\u0442\u0443 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0438\u044f. \u0414\u0430\u0442\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0438\u044f \u044d\u0442\u043e \u043e\u0434\u0438\u043d \u0438\u0437 \u0430\u0442\u0440\u0438\u0431\u0443\u0442\u043e\u0432 \u043f\u043e\u0434\u043f\u0438\u0441\u0438 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 ASN.1. \u0414\u043b\u044f \u0435\u0433\u043e \u0438\u0437\u0432\u043b\u0435\u0447\u0435\u043d\u0438\u044f \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 asn1_string_st \u0438 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u043d\u0435\u043c \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0430\u0442\u0440\u0438\u0431\u0443\u0442 Pkcs9SigningTime. <\/p>\n<p>  <\/p>\n<p>\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043d\u043d\u043e \u043e\u0442\u0434\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\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">\/**&lt;summary&gt;\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u0430&lt;\/summary&gt; * &lt;param name=\"_hSignerInfo\"&gt;\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e\u0431 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u0435&lt;\/param&gt; * &lt;param name=\"_pCert\"&gt;\u0412\u043e\u0437\u0432\u0440\u0430\u0442 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430&lt;\/param&gt; * &lt;param name=\"_pCerts\"&gt;\u0421\u043f\u0438\u0441\u043e\u043a \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u0433\u0434\u0435 \u0438\u0441\u043a\u0430\u0442\u044c&lt;\/param&gt; * &lt;param name=\"_sError\"&gt;\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0430\u044f \u0441\u0442\u0440\u043e\u043a\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 GetSignerInfoCertOS(IntPtr _hSignerInfo, X509Certificate2Collection _pCerts,                                         out X509Certificate2 _pCert, ref string _sError) {     _pCert = null;     try {         \/\/ 0) \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431 \u0430\u0434\u0440\u0435\u0441\u0430\u0442\u0435         IntPtr hKey    = IntPtr.Zero;         IntPtr hIssuer = IntPtr.Zero;         IntPtr hSNO    = IntPtr.Zero;         if (!UOpenSSLAPI.CMS_SignerInfo_get0_signer_id(_hSignerInfo, ref hKey, ref hIssuer, ref hSNO))              return RetErrOS(ref _sError, UCConsts.S_GET_RECEIP_INFO_ERR);         \/\/ 1) \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442\u0441\u044f \u0441\u0435\u0440\u0438\u0439\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440         string sSerial;         int iRes = GetBinaryHexFromASNOS(hSNO, out sSerial, ref _sError);         if(iRes != UConsts.S_OK) return iRes;         X509Certificate2Collection pResCerts = _pCerts.Find(X509FindType.FindBySerialNumber, sSerial, false);         if(pResCerts.Count == 0) return RetErrOS(ref _sError, UCConsts.S_NO_CERTIFICATE, UConsts.E_NO_CERTIFICATE);         _pCert = pResCerts[0];         return UConsts.S_OK;     } catch (Exception E) {         _sError = UCConsts.S_GET_SIGN_INFO_GEN_ERR.Frm(E.Message);         return UConsts.E_GEN_EXCEPTION;     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0412\u043d\u0430\u0447\u0430\u043b\u0435 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442\u0441\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u0441\u0435\u0440\u0438\u0439\u043d\u043e\u043c \u043d\u043e\u043c\u0435\u0440\u0435 \u0438 \u0438\u0437\u0434\u0430\u0442\u0435\u043b\u0435, \u0430 \u0437\u0430\u0442\u0435\u043c \u043f\u043e \u043d\u0435\u043c\u0443 \u0438\u0437 \u0440\u0430\u043d\u0435\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442\u0441\u044f \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442. \u0421\u0435\u0440\u0438\u0439\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440 \u043f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0438\u0437 \u0441\u0435\u0431\u044f \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 asn1_string_st, \u0438\u0437 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044e\u0442\u0441\u044f \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u0443\u044e\u0442\u0441\u044f \u0432 hex \u0444\u043e\u0440\u043c\u0430\u0442:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c hex \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0445 ANS.1<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\"> \/**&lt;summary&gt;\u041f\u043e\u043b\u0443\u0447\u0438\u0442\u044c Hex \u043e\u0442\u043e\u0431\u0440\u0430\u0436\u0435\u043d\u0438\u0435 \u0431\u0438\u043d\u0430\u0440\u043d\u044b\u0445 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 ASN.1&lt;\/summary&gt; * &lt;param name=\"_hASN\"&gt;\u0421\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u044d\u043b\u0435\u043c\u0435\u043d\u0442 ASN.1&lt;\/param&gt; * &lt;param name=\"_sError\"&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=\"_sHexData\"&gt;\u0414\u0430\u043d\u043d\u044b\u0435 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 Hex&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 GetBinaryHexFromASNOS(IntPtr _hASN, out string _sHexData, ref string _sError) {     _sHexData = \"\";     try {         asn1_string_st pSerial = (asn1_string_st)Marshal.PtrToStructure(_hASN, typeof(asn1_string_st));         byte[] arStr = new byte[pSerial.iLength];         Marshal.Copy(pSerial.hData, arStr, 0, (int)pSerial.iLength);         _sHexData = arStr.ToHex().ToUpper();         return UConsts.S_OK;     } catch (Exception E) {         _sError = UCConsts.S_HEX_ASN_BINARY_ERR.Frm(E.Message);         return UConsts.E_GEN_EXCEPTION;     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u043f\u043e\u0434\u043f\u0438\u0441\u0438 \u041a\u0440\u0438\u043f\u0442\u043e\u041f\u0440\u043e, \u043f\u043e\u0438\u0441\u043a\u0430 \u043f\u043e \u0441\u0435\u0440\u0438\u0439\u043d\u043e\u043c\u0443 \u043d\u043e\u043c\u0435\u0440\u0443 \u043e\u0431\u044b\u0447\u043d\u043e \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e, \u0447\u0442\u043e\u0431\u044b \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e \u0438\u0434\u0435\u043d\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442.<\/p>\n<p>  <\/p>\n<h2>\u0428\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h2>\n<p>  <\/p>\n<p>\u0428\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 OpenSSL \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u043b\u043e\u0433\u0438\u0447\u043d\u044b\u043c \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u043c:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0428\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;\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=\"_arInput\"&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=\"_pReceipients\"&gt;\u0421\u043f\u0438\u0441\u043e\u043a \u0441\u0435\u0440\u0442\u0444\u0438\u0438\u043a\u0430\u0442\u043e\u0432 \u0430\u0434\u0440\u0435\u0441\u0430\u0442\u043e\u0432&lt;\/param&gt; * &lt;param name=\"_arRes\"&gt;\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442&lt;\/param&gt; * &lt;param name=\"_sError\"&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; * **\/ internal static int EncryptDataOS(byte[] _arInput, List&lt;X509Certificate2&gt; _pReceipients, out byte[] _arRes,                                    ref string _sError) {     _arRes           = new byte[0];     uint iFlags      = UCConsts.CMS_BINARY;     IntPtr hData     = IntPtr.Zero;     IntPtr hReceipts = IntPtr.Zero;     IntPtr hBIORes   = IntPtr.Zero;     IntPtr hCMS      = IntPtr.Zero;     try {         \/\/ 0) \u0421\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c BIO \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f         int iRes = GetBIOByBytesOS(_arInput, out hData, ref _sError);         if (iRes != UConsts.S_OK) return iRes;         \/\/ 1) \u0424\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u0435\u043a\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u0430\u0434\u0440\u0435\u0441\u0430\u0442\u043e\u0432         iRes = GetCertsStackOS(_pReceipients, out hReceipts, ref _sError);         if (iRes != UConsts.S_OK) return iRes;         \/\/ 2) \u0424\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 CMS         hCMS = UOpenSSLAPI.CMS_encrypt(hReceipts, hData, UOpenSSLAPI.EVP_des_ede3_cbc(), iFlags);         if (hCMS == IntPtr.Zero) return RetErrOS(ref _sError, UCConsts.S_ENC_CMS_ERR);         \/\/ 3) \u0417\u0430\u043f\u0438\u0441\u044c CMS \u0432 BIO         hBIORes = UOpenSSLAPI.BIO_new(UOpenSSLAPI.BIO_s_mem());         if (!UOpenSSLAPI.i2d_CMS_bio_stream(hBIORes, hCMS, IntPtr.Zero, iFlags))              return RetErrOS(ref _sError, UCConsts.S_OS_CMS_EXP_TO_BIO_ERR);         \/\/ 4) \u041f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u0438\u0437 BIO \u0432 \u043d\u0430\u0431\u043e\u0440 \u0431\u0430\u0439\u0442         return ReadFromBIO_OS(hBIORes, out _arRes, ref _sError);     } catch (Exception E) {         _sError = UCConsts.S_ENC_OS_GEN_ERR.Frm(E.Message);         return UConsts.E_GEN_EXCEPTION;     } finally {         if(hBIORes != IntPtr.Zero) UOpenSSLAPI.BIO_free(hBIORes);         if(hData != IntPtr.Zero) UOpenSSLAPI.BIO_free(hData);         if(hCMS != IntPtr.Zero) UOpenSSLAPI.CMS_ContentInfo_free(hCMS);         if(hReceipts != IntPtr.Zero) UOpenSSLAPI.sk_free(hReceipts);     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0412 \u043d\u0430\u0447\u0430\u043b\u0435 \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f BIO \u0441 \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0438 \u0441\u043f\u0438\u0441\u043e\u043a \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u2014 \u0430\u0434\u0440\u0435\u0441\u0430\u0442\u043e\u0432. \u0418\u043c\u0435\u043d\u043d\u043e \u0432 \u0430\u0434\u0440\u0435\u0441 \u044d\u0442\u0438\u0445 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435. \u0417\u0430\u0442\u0435\u043c \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043d\u0435\u043f\u043e\u0441\u0440\u0435\u0434\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435, \u0438 \u0443\u0436\u0435 \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0433\u043e \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 BIO \u044d\u043a\u0441\u043f\u043e\u0440\u0442\u0438\u0440\u0443\u044e\u0442\u0441\u044f \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u0431\u0430\u0439\u0442. OpenSSL \u043e\u0431\u043b\u0430\u0434\u0430\u0435\u0442 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0431\u043e\u043b\u044c\u0448\u0438\u043c \u043d\u0430\u0431\u043e\u0440\u043e\u043c \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u043e\u0432 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043e\u0434\u043d\u043e\u0437\u043d\u0430\u0447\u043d\u043e \u0432\u044b\u0431\u0440\u0430\u0442\u044c \u0435\u0433\u043e, \u043a\u0430\u043a \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0434\u043b\u044f \u041a\u0440\u0438\u043f\u0442\u043e\u041f\u0440\u043e, \u0432\u0440\u044f\u0434 \u043b\u0438 \u0443\u0434\u0430\u0441\u0442\u0441\u044f. \u0412 \u0441\u0438\u043b\u0443 \u044d\u0442\u0438\u0445 \u043f\u0440\u0438\u0447\u0438\u043d \u043b\u0438\u0431\u043e \u043d\u0430\u0434\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0447\u0430\u0441\u0442\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c\u044b\u0439 EVP_des_ede3_cbc, \u043b\u0438\u0431\u043e \u043f\u0435\u0440\u0435\u043b\u043e\u0436\u0438\u0442\u044c \u044d\u0442\u043e\u0442 \u0432\u044b\u0431\u043e\u0440 \u043d\u0430 \u0432\u044b\u0437\u044b\u0432\u0430\u044e\u0449\u0443\u044e \u0441\u0442\u043e\u0440\u043e\u043d\u0443.<\/p>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u0442\u0435\u043a\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u0430\u0434\u0440\u0435\u0441\u0430\u0442\u043e\u0432 \u0441\u0442\u043e\u0438\u0442 \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u043c\u0435\u0442\u043e\u0434, \u0442.\u00a0\u043a. \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 \u0441\u043e \u0441\u0442\u0435\u043a\u043e\u043c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u0434\u043e\u0432\u043e\u043b\u044c\u043d\u043e \u0447\u0430\u0441\u0442\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u043c\u0435\u0442\u043e\u0434\u0430\u0445 OpenSSL:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0424\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0441\u0442\u0435\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 \u0441\u0442\u0435\u043a \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432&lt;\/summary&gt;* &lt;param name=\"_hStack\"&gt;\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u044b\u0439 \u0441\u0442\u0435\u043a&lt;\/param&gt; * &lt;param name=\"_pCerts\"&gt;\u0421\u043f\u0438\u0441\u043e\u043a \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432&lt;\/param&gt; * &lt;param name=\"_sError\"&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\u0438&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 GetCertsStackOS(List&lt;X509Certificate2&gt; _pCerts, out IntPtr _hStack, ref string _sError) {     _hStack       = IntPtr.Zero;     IntPtr hStack = IntPtr.Zero;     try {         hStack = UOpenSSLAPI.sk_new_null();         foreach (X509Certificate2 pCert in _pCerts) {             \/\/ 0) \u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u043a\u043b\u0430\u0441\u0441, \u0447\u0442\u043e\u0431\u044b \u043d\u0435 \u0431\u044b\u043b\u043e \u0443\u0442\u0435\u0447\u0435\u043a             ISDP_X509Cert pLocCert = ISDP_X509Cert.Convert(pCert, TCryptoPath.cpOpenSSL);             \/\/ 1) \u0414\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c             UOpenSSLAPI.sk_push(hStack, pLocCert.hRealHandle);         }         _hStack = hStack;         hStack = IntPtr.Zero;         return UConsts.S_OK;     } catch (Exception E) {          _sError = UCConsts.S_GEN_CERT_STACK_ERR.Frm(E.Message);         return UConsts.E_GEN_EXCEPTION;     } finally {         if(hStack != IntPtr.Zero) UOpenSSLAPI.sk_free(hStack);     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<h2>\u0414\u0435\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435<\/h2>\n<p>  <\/p>\n<p>\u0414\u0435\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043d\u0430 \u043c\u0430\u0448\u0438\u043d\u0435, \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u043e\u0439 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0439 \u043a\u043b\u044e\u0447 \u043e\u0434\u043d\u043e\u0433\u043e \u0438\u0437 \u0430\u0434\u0440\u0435\u0441\u0430\u0442\u043e\u0432. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0434\u0435\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0438\u043c \u043f\u0443\u0442\u0435\u043c:<\/p>\n<p>  <\/p>\n<ol>\n<li>\u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u0442\u0441\u044f, \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043c\u0430\u0441\u0441\u0438\u0432\u0430 \u0434\u0430\u043d\u043d\u044b\u0445;<\/li>\n<li>\u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442\u0441\u044f \u0441\u043f\u0438\u0441\u043e\u043a \u0430\u0434\u0440\u0435\u0441\u0430\u0442\u043e\u0432;<\/li>\n<li>\u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0430\u0434\u0440\u0435\u0441\u0430\u0442\u0430 \u043f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043d\u0430\u0439\u0442\u0438 \u0435\u0433\u043e \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 \u043d\u0430 \u043c\u0430\u0448\u0438\u043d\u0435 \u0438 \u0434\u0435\u0448\u0438\u0444\u0440\u043e\u0432\u0430\u0442\u044c; <\/li>\n<li>\u0435\u0441\u043b\u0438 \u0443\u0434\u0430\u043b\u043e\u0441\u044c \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u043e\u0431\u0449\u0435\u0435 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u043d\u0438\u0435;<\/li>\n<li>\u043f\u043e\u0441\u043b\u0435 \u0447\u0435\u0433\u043e \u0432\u044b\u0433\u0440\u0443\u0436\u0430\u0435\u043c \u0438\u0437 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0433\u043e BIO \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043c\u0430\u0441\u0441\u0438\u0432 \u0431\u0430\u0439\u0442;<\/li>\n<\/ol>\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=\"_arInput\"&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=\"_arRes\"&gt;\u0420\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442&lt;\/param&gt; * &lt;param name=\"_pLocation\"&gt;\u041c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430, \u0433\u0434\u0435 \u0438\u0441\u043a\u0430\u0442\u044c&lt;\/param&gt; * &lt;param name=\"_sError\"&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=\"_pCert\"&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; * **\/ internal static int DecryptDataOS(byte[] _arInput, out X509Certificate2 _pCert, out byte[] _arRes, ref string _sError,                                    StoreLocation _pLocation = StoreLocation.CurrentUser ) {                  _arRes = new byte[0];     _pCert = null;     uint   iFlag    = UCConsts.CMS_BINARY;     IntPtr hBIORes  = IntPtr.Zero;     IntPtr hCMS     = IntPtr.Zero;     X509Certificate2 pCert;     try {         \/\/ 0) \u0427\u0442\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b CMS         int iRes = GetCMSFromBytesOS(_arInput, out hCMS, ref _sError);         if (iRes != UConsts.S_OK) return iRes;         \/\/ 1) \u041f\u0440\u043e\u0445\u043e\u0438\u043c \u043f\u043e \u0441\u043f\u0438\u0441\u043a\u0443 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u043e\u0432         IntPtr hReceipts =  UOpenSSLAPI.CMS_get0_RecipientInfos(hCMS);         int iCnt = UOpenSSLAPI.sk_num(hReceipts);                         for(int i = 0; i &lt; iCnt; i++) {                              IntPtr hRecep    = UOpenSSLAPI.sk_value(hReceipts, i);                                 iRes = GetRecepInfoCertOS(hRecep, _pLocation, out pCert, ref _sError);             if (iRes != UConsts.S_OK &amp;&amp; iRes != UConsts.E_NO_CERTIFICATE) return iRes;             \/\/ 1.1) \u041d\u0435\u0442 \u0441\u0435\u0440\u0442\u0444\u0438\u043a\u0430\u0442\u0430              if (iRes == UConsts.E_NO_CERTIFICATE)  continue;             ISDP_X509Cert pLocCert = ISDP_X509Cert.Convert(pCert);             \/\/ 1.2) \u041d\u0435\u0442 \u0437\u0430\u0440\u044b\u0442\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430             if (pLocCert.hOSKey == IntPtr.Zero)  continue;             \/\/ 1.3) \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043a\u043b\u044e\u0447\u0430             if (!UOpenSSLAPI.CMS_RecipientInfo_set0_pkey(hRecep, pLocCert.hOSKey))                  return RetErrOS(ref _sError, UCConsts.S_OS_CMS_SET_DEC_KEY_ERR);             try {                 \/\/ 1.4) \u0414\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435                 if (!UOpenSSLAPI.CMS_RecipientInfo_decrypt(hCMS, hRecep))                     return RetErrOS(ref _sError, UCConsts.S_OS_CMS_REC_DEC_ERR);             } finally {                 \/\/ !! \u0418\u043d\u0430\u0447\u0435 \u0434\u0432\u0430 \u043e\u0441\u0432\u043e\u0431\u043e\u0436\u0434\u0435\u043d\u0438\u044f \u0438 \u043e\u0448\u0438\u0431\u043a\u0430                 UOpenSSLAPI.CMS_RecipientInfo_set0_pkey(hRecep, IntPtr.Zero);             }             \/\/ 1.5) \u041e\u0431\u0449\u0435\u0435 \u0434\u0435\u043a\u043e\u0434\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435             hBIORes = UOpenSSLAPI.BIO_new(UOpenSSLAPI.BIO_s_mem());             if (!UOpenSSLAPI.CMS_decrypt(hCMS, IntPtr.Zero, pLocCert.hRealHandle, IntPtr.Zero, hBIORes, iFlag))                 return RetErrOS(ref _sError, UCConsts.S_OS_CMS_FULL_DEC_ERR);             _pCert = pLocCert;             \/\/ 2) \u0421\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u0438\u0437 BIO                                 return ReadFromBIO_OS(hBIORes, out _arRes, ref _sError);         }         _sError = UCConsts.S_DEC_NO_CERT_ERR;         return UConsts.E_NO_CERTIFICATE;     } catch (Exception E) {         _sError = UCConsts.S_DEC_GEN_ERR.Frm(E.Message);         return UConsts.E_GEN_EXCEPTION;     } finally {         if(hBIORes != IntPtr.Zero) UOpenSSLAPI.BIO_free(hBIORes);         if(hCMS != IntPtr.Zero) UOpenSSLAPI.CMS_ContentInfo_free(hCMS);     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0412\u0430\u0436\u043d\u043e\u0439 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u044c\u044e \u044f\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0441\u043b\u0435\u0434\u0438\u0442\u044c \u0437\u0430 \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u043c \u043a\u043b\u044e\u0447\u043e\u043c. \u0414\u0435\u043b\u043e \u0432 \u0442\u043e\u043c, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0441\u0441\u044b\u043b\u043a\u0443 \u043d\u0430 \u043d\u0435\u0433\u043e \u0437\u0430\u0444\u0438\u043a\u0441\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0432 \u0430\u0434\u0440\u0435\u0441\u0430\u0442\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u043c CMS_RecipientInfo_set0_pkey, \u0442\u043e \u043e\u043d\u0430 \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u0442\u044c\u0441\u044f \u0432\u043c\u0435\u0441\u0442\u0435 \u0441\u043e \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u043e\u0439 CMS, \u0438 \u043f\u0440\u0438 \u043f\u043e\u043f\u044b\u0442\u043a\u0435 \u0435\u0433\u043e \u043e\u0441\u0432\u043e\u0431\u043e\u0434\u0438\u0442\u044c \u0432\u043c\u0435\u0441\u0442\u0435 \u0441 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u043c \u0441\u0438\u0441\u0442\u0435\u043c\u0430 \u0443\u043f\u0430\u0434\u0435\u0442 \u0441 \u043e\u0448\u0438\u0431\u043a\u043e\u0439.<\/p>\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, \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431 \u0430\u0434\u0440\u0435\u0441\u0430\u0442\u0435 \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u0430\u0442\u044c \u0432 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442. \u0422\u0430\u043a \u0436\u0435 \u043a\u0430\u043a \u0438 \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u043e\u043c, \u0432 \u0434\u0430\u043d\u043d\u044b\u0445 \u0445\u0440\u0430\u043d\u0438\u0442\u044c\u0441\u044f \u0441\u0435\u0440\u0438\u0439\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440 \u0438 \u0438\u0437\u0434\u0430\u0442\u0435\u043b\u044c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430. \u0414\u043b\u044f \u043f\u0440\u043e\u0441\u0442\u043e\u0442\u044b \u043c\u043e\u0436\u043d\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0438\u0442\u0441\u044f \u0441\u0435\u0440\u0438\u0439\u043d\u044b\u043c \u043d\u043e\u043c\u0435\u0440\u043e\u043c \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430:<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 \u0430\u0434\u0440\u0435\u0441\u0430\u0442\u0430<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">\/**&lt;summary&gt;\u041f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 \u0430\u0434\u0440\u0435\u0441\u0430\u0442\u0430&lt;\/summary&gt; * &lt;param name=\"_hRecep\"&gt;\u0418\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e\u0431 \u0430\u0434\u0440\u0435\u0441\u0430\u0442\u0435&lt;\/param&gt; * &lt;param name=\"_pCert\"&gt;\u0412\u043e\u0437\u0432\u0440\u0430\u0442 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430&lt;\/param&gt; * &lt;param name=\"_pLocation\"&gt;\u0420\u0430\u0441\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u044f \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430 \u0434\u043b\u044f \u043f\u043e\u0438\u0441\u043a\u0430&lt;\/param&gt; * &lt;param name=\"_sError\"&gt;\u0412\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0430\u044f \u0441\u0442\u0440\u043e\u043a\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 GetRecepInfoCertOS(IntPtr _hRecep, StoreLocation _pLocation,                                        out X509Certificate2 _pCert, ref string _sError) {     _pCert = null;     try {          \/\/ 0) \u041f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e\u0431 \u0430\u0434\u0440\u0435\u0441\u0430\u0442\u0435          IntPtr hKey    = IntPtr.Zero;          IntPtr hIssuer = IntPtr.Zero;          IntPtr hSNO    = IntPtr.Zero;          if (!UOpenSSLAPI.CMS_RecipientInfo_ktri_get0_signer_id(_hRecep, ref hKey,                                                                 ref hIssuer, ref hSNO))              return RetErrOS(ref _sError, UCConsts.S_GET_RECEIP_INFO_ERR);          \/\/ 1) \u0418\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442\u0441\u044f \u0441\u0435\u0440\u0438\u0439\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440          string sSerial;          int iRes = GetBinaryHexFromASNOS(hSNO, out sSerial, ref _sError);          if(iRes != UConsts.S_OK) return iRes;          \/\/ 2) \u0418\u0449\u0435\u043c \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442          iRes = FindCertificateOS(sSerial, out _pCert, ref _sError, _pLocation,                                    StoreName.My, X509FindType.FindBySerialNumber);          if(iRes != UConsts.S_OK) return iRes;          return UConsts.S_OK;     } catch (Exception E) {          _sError = UCConsts.S_GET_RECEIP_INFO_GEN_ERR.Frm(E.Message);          return UConsts.E_GEN_EXCEPTION;     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041c\u0435\u0442\u043e\u0434 CMS_RecipientInfo_ktri_get0_signer_id \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0435 \u0430\u0434\u0440\u0435\u0441\u0430\u0442\u0430, \u0430 \u0438\u0437 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u043d\u0430 \u043a\u043e\u0442\u043e\u0440\u0443\u044e \u0441\u0441\u044b\u043b\u0430\u0435\u0442\u0441\u044f \u043f\u0435\u0440\u0435\u043c\u0435\u043d\u043d\u0430\u044f hSNO \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u0435\u0442\u0441\u044f \u0441\u0430\u043c \u0441\u0435\u0440\u0438\u0439\u043d\u044b\u0439 \u043d\u043e\u043c\u0435\u0440 \u0443\u0436\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u044b\u043c \u0440\u0430\u043d\u0435\u0435 \u043c\u0435\u0442\u043e\u0434\u043e\u043c. \u041e\u0441\u0442\u0430\u0435\u0442\u0441\u044f \u043d\u0430\u0439\u0442\u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 \u043f\u043e \u0441\u0435\u0440\u0438\u0439\u043d\u043e\u043c\u0443 \u043d\u043e\u043c\u0435\u0440\u0443. <\/p>\n<p>  <\/p>\n<p>C\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0430 \u0434\u0430\u043d\u043d\u044b\u0445 \u0430\u0434\u0440\u0435\u0441\u0430\u0442\u0430, \u0432\u043e\u043e\u0431\u0449\u0435 \u0433\u043e\u0432\u043e\u0440\u044f, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c <a href=\"https:\/\/tools.ietf.org\/html\/rfc3211\">\u0440\u0430\u0437\u043d\u043e\u0439<\/a>. \u041d\u043e \u043f\u0440\u0438 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0438 \u0434\u043e\u043a\u0443\u043c\u0435\u043d\u0442\u043e\u0432 \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0432\u0441\u0442\u0440\u0435\u0447\u0430\u0435\u0442\u0441\u044f \u0438\u043c\u0435\u043d\u043d\u043e \u0442\u0438\u043f ktri \u2014 \u0441 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u0435\u043c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043e\u0431 \u043e\u0442\u043a\u0440\u044b\u0442\u044b\u0445 \u043a\u043b\u044e\u0447\u0430\u0445. \u0414\u043b\u044f \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0434\u0440\u0443\u0433\u0438\u043c\u0438 \u0442\u0438\u043f\u0430\u043c\u0438 OpenSSL \u0442\u043e\u0436\u0435 \u0440\u0435\u0430\u043b\u0438\u0437\u043e\u0432\u0430\u043b\u043e \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u043c\u0435\u0442\u043e\u0434\u043e\u0432: CMS_RecipientInfo_kari_*, CMS_RecipientInfo_kekri_* \u0438 \u043c\u0435\u0442\u043e\u0434 CMS_RecipientInfo_set0_password \u0434\u043b\u044f pwri.<\/p>\n<p>  <\/p>\n<h2>\u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430<\/h2>\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 \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043e \u043f\u043e\u0434\u043f\u0438\u0441\u0430\u043d\u0442\u0435 \u0437\u0430\u0432\u0435\u0440\u0435\u043d\u043d\u0430\u044f \u0438\u0437\u0434\u0430\u0442\u0435\u043b\u0435\u043c \u044d\u0442\u043e\u0433\u043e \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430. \u0414\u0430\u043d\u043d\u0430\u044f \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u0430\u043a\u0442\u0443\u0430\u043b\u044c\u043d\u0430 \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0433\u0440\u0430\u043d\u0438\u0447\u0435\u043d\u043d\u043e\u0435 \u0432\u0440\u0435\u043c\u044f \u0438 \u0438\u0437\u0434\u0430\u0442\u0435\u043b\u044c \u0441\u0432\u043e\u044e \u043f\u043e\u0434\u043f\u0438\u0441\u044c \u043f\u043e\u0434 \u043d\u0438\u043c \u043c\u043e\u0436\u0435\u0442 \u0438 \u043e\u0442\u043e\u0437\u0432\u0430\u0442\u044c. \u0412\u0441\u0435 \u044d\u0442\u043e \u0437\u0430\u0441\u0442\u0430\u0432\u043b\u044f\u0435\u0442 \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u043e\u0442\u043d\u043e\u0441\u0438\u0442\u044c\u0441\u044f \u043a \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0441\u0442\u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430, \u0442.\u00a0\u043a. \u044d\u0442\u043e \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u044f\u0435\u0442 \u0432\u0430\u043b\u0438\u0434\u043d\u043e\u0441\u0442\u044c \u0441\u043e\u0432\u0435\u0440\u0448\u0435\u043d\u043d\u044b\u0445 \u0441 \u0435\u0433\u043e \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0439. \u0412 OpenSSL \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0430 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u043d\u0435\u043f\u043b\u043e\u0445\u043e \u0430\u0432\u0442\u043e\u043c\u0430\u0442\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u043d\u0430. \u041f\u043e \u0441\u0443\u0442\u0438 \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0442\u043e\u043b\u044c\u043a\u043e \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 (\u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0438\u043b\u0438 \u043d\u0430 \u0434\u0438\u0441\u043a\u0435), \u043f\u043e \u043a\u043e\u0442\u043e\u0440\u044b\u043c \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u043e\u0445\u043e\u0434\u0438\u0442\u044c \u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0446\u0435\u043f\u043e\u0447\u043a\u0438, \u0443\u043a\u0430\u0437\u0430\u0442\u044c \u0434\u0430\u0442\u0443 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0438 \u043d\u0430\u0431\u043e\u0440 \u0444\u043b\u0430\u0433\u043e\u0432.  <\/p>\n<p>\u0421\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442, \u043f\u043e \u0445\u043e\u0440\u043e\u0448\u0435\u043c\u0443, \u043d\u0443\u0436\u043d\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c \u043f\u043e\u043b\u043d\u043e\u0441\u0442\u044c\u044e, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0444\u043b\u0430\u0433\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0447\u0430\u0449\u0435 \u0432\u0441\u0435\u0433\u043e \u0431\u0443\u0434\u0443\u0442 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043b\u0435\u043d\u044b \u043e\u0434\u043d\u0438 \u0438 \u0442\u0435 \u0436\u0435:<\/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 \u0432 \u0440\u0430\u043c\u043a\u0430\u0445 OpenSSL&lt;\/summary&gt; * &lt;param name=\"_iRevFlag\"&gt;\u0424\u043b\u0430\u0433 \u043e\u0442\u0437\u044b\u0432\u0430&lt;\/param&gt; * &lt;param name=\"_iRevMode\"&gt;\u0420\u0435\u0436\u0438\u043c \u043e\u0442\u0437\u044b\u0432\u0430&lt;\/param&gt; * &lt;param name=\"_hCert\"&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=\"_rOnDate\"&gt;\u0414\u0430\u0442\u0430 \u0432\u0435\u0440\u0438\u0444\u0438\u043a\u0430\u0446\u043c\u043c&lt;\/param&gt; * &lt;param name=\"_pLocation\"&gt;\u041c\u0435\u0441\u0442\u043e\u043f\u043e\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438&lt;\/param&gt; * &lt;param name=\"_sError\"&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 VerifyCertificateOS(IntPtr _hCert, X509RevocationMode _iRevMode, X509RevocationFlag _iRevFlag,                                         StoreLocation _pLocation, DateTime _rOnDate, ref string _sError) {     IntPtr hStore   = IntPtr.Zero;     IntPtr hStoreCtx = IntPtr.Zero;     try {                                                     \/\/ 0) \u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0435         int iRes = GetTrustStoreOS(_pLocation, out hStore, ref _sError);         if(iRes != UConsts.S_OK) return iRes;         \/\/ 1) \u0424\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438         hStoreCtx = UOpenSSLAPI.X509_STORE_CTX_new();         if (!UOpenSSLAPI.X509_STORE_CTX_init(hStoreCtx, hStore, _hCert, IntPtr.Zero)) {             _sError = UCConsts.S_CRYPTO_CONTEXT_CER_ERR;             return UConsts.E_CRYPTO_ERR;         }         \/\/ 2) \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c \u0434\u0430\u0442\u0443 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0438 \u0434\u043e\u043f \u0444\u043b\u0430\u0433\u0438         SetStoreCtxCheckDate(hStoreCtx, _rOnDate);         \/\/ 3) \u041f\u0440\u043e\u0432\u0435\u0440\u043a\u0430         if (!UOpenSSLAPI.X509_verify_cert(hStoreCtx)) {             _sError = UCConsts.S_CRYPTO_CHAIN_CHECK_ERR.Frm(GetCertVerifyErr(hStoreCtx));             return UConsts.E_CRYPTO_ERR;         }         return UConsts.S_OK;     } finally {         if (hStore != IntPtr.Zero) UOpenSSLAPI.X509_STORE_free(hStore);         if (hStoreCtx != IntPtr.Zero) UOpenSSLAPI.X509_STORE_CTX_free(hStoreCtx);     } } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u0412 \u0441\u0444\u043e\u0440\u043c\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u043a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 (X509_STORE_CTX) \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e \u043f\u0440\u043e\u043f\u0438\u0441\u0430\u0442\u044c \u0434\u0430\u0442\u0443 \u0438 \u0444\u043b\u0430\u0433\u0438. \u0414\u0435\u043b\u0430\u0442\u044c \u044d\u0442\u043e \u0443\u0434\u043e\u0431\u043d\u0435\u0435 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u043c\u0435\u0442\u043e\u0434\u0435: <\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0434\u0430\u0442\u044b \u0438 \u0444\u043b\u0430\u0433\u043e\u0432 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"cs\">\/**&lt;summary&gt;\u0423\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u0442\u044c \u0434\u0430\u0442\u0443 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430&lt;\/summary&gt; * &lt;param name=\"_hStoreCtx\"&gt;\u041a\u043e\u043d\u0442\u0435\u043a\u0441\u0442 \u0445\u0440\u0430\u043d\u0438\u043b\u0438\u0449\u0430&lt;\/param&gt; * &lt;param name=\"_rDate\"&gt;\u0414\u0430\u0442\u0430&lt;\/param&gt; * **\/ public static void SetStoreCtxCheckDate(IntPtr _hStoreCtx, DateTime _rDate) {     uint iFlags = UCConsts.X509_V_FLAG_USE_CHECK_TIME | UCConsts.X509_V_FLAG_X509_STRICT |                    UCConsts.X509_V_FLAG_CRL_CHECK_ALL;     \/\/ \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0444\u043b\u0430\u0433\u043e\u0432     UOpenSSLAPI.X509_STORE_CTX_set_flags(_hStoreCtx, iFlags);     \/\/ \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u0432\u0440\u0435\u043c\u0435\u043d\u0438     UOpenSSLAPI.X509_STORE_CTX_set_time(_hStoreCtx, iFlags, (uint)_rDate.ToUnix());     \/\/ \u0423\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0430 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u0441\u0442\u0432 - \u0432\u0441\u0435 \u0432\u0435\u0440\u0438\u0444\u0438\u0444\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b     UOpenSSLAPI.X509_STORE_CTX_set_trust(_hStoreCtx, UCConsts.X509_TRUST_TRUSTED); } <\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0443\u0436\u0435 \u0431\u044b\u043b\u043e \u043e\u043f\u0438\u0441\u0430\u043d\u043e \u0440\u0430\u043d\u0435\u0435, \u043e\u0448\u0438\u0431\u043a\u0438 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u0438 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u043f\u043e\u043f\u0430\u0434\u0430\u044e\u0442 \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u0438 \u0438\u0437\u0432\u043b\u0435\u043a\u0430\u044e\u0442\u0441\u044f \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u044b\u043c \u043c\u0435\u0442\u043e\u0434\u043e\u043c.<\/p>\n<p>  <\/p>\n<h1>\u0417\u0430\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435<\/h1>\n<p>  <\/p>\n<p>\u0414\u0430\u043d\u043d\u044b\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u0440\u0435\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0431\u044b\u043b \u043f\u0440\u043e\u0442\u0435\u0441\u0442\u0438\u0440\u043e\u0432\u0430\u043d, \u043f\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u043c\u0443 \u0432 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435. \u041f\u043e\u0441\u043b\u0435 \u0443\u0441\u0442\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0440\u0430\u043d\u0435\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u043d\u043e\u0439 \u0443\u0442\u0435\u0447\u043a\u0438 \u0432 X509Certificate2 (mono) \u043e\u043d \u0441\u0442\u0430\u0431\u0438\u043b\u044c\u043d\u043e \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u0431\u0435\u0437 \u0443\u0442\u0435\u0447\u0435\u043a \u043f\u0430\u043c\u044f\u0442\u0438. \u0421\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u0441\u043e\u0438\u0437\u043c\u0435\u0440\u0438\u043c\u0430 \u0441 \u0440\u0430\u0431\u043e\u0442\u043e\u0439 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438 \u041a\u0440\u0438\u043f\u0442\u043e\u041f\u0440\u043e.<\/p>\n<p>  <\/p>\n<p>\u0412 \u0446\u0435\u043b\u043e\u043c \u0436\u0435, \u0434\u043b\u044f Windows \u0432 \u0441\u0438\u043b\u0443 \u043e\u0441\u043e\u0431\u0435\u043d\u043d\u043e\u0441\u0442\u0435\u0439 \u0445\u0440\u0430\u043d\u0435\u043d\u0438\u044f \u0438 \u0440\u0430\u0431\u043e\u0442\u044b \u0441 \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u043c\u0438 \u043a\u043b\u044e\u0447\u0430\u043c\u0438 \u044d\u0442\u0430 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0430 \u043d\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u0440\u0438\u043c\u0435\u043d\u0438\u043c\u0430. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0442\u043e\u0438\u0442 \u0441\u043a\u043e\u0440\u0435\u0435 \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0448\u0442\u0430\u0442\u043d\u044b\u043c\u0438 \u043f\u0440\u043e\u0446\u0435\u0434\u0443\u0440\u0430\u043c\u0438 \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0438. \u0412 Linux \u0436\u0435, \u0435\u0441\u043b\u0438 \u0437\u0430\u043a\u0440\u044b\u0442\u044c \u0433\u043b\u0430\u0437\u0430 \u043d\u0430 \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u043e\u0441\u0442\u044c \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0438 \u0437\u0430\u043a\u0440\u044b\u0442\u044b\u0445 \u043a\u043b\u044e\u0447\u0435\u0439, \u0434\u043b\u044f \u043d\u0435 \u0413\u041e\u0421\u0422\u043e\u0432\u043e\u0439 \u043a\u0440\u0438\u043f\u0442\u043e\u0433\u0440\u0430\u0444\u0438\u0438 \u044d\u0442\u043e \u0432\u043f\u043e\u043b\u043d\u0435 \u0440\u0430\u0431\u043e\u0447\u0438\u0439 \u0432\u0430\u0440\u0438\u0430\u043d\u0442.<\/p>\n<p>  <\/p>\n<p>\u0412 \u0442\u043e\u0436\u0435 \u0432\u0440\u0435\u043c\u044f \u041a\u0440\u0438\u043f\u0442\u043e\u041f\u0440\u043e \u0443\u0436\u0435 \u0432\u044b\u043f\u0443\u0441\u0442\u0438\u043b\u0430 <a href=\"https:\/\/www.cryptopro.ru\/products\/csp_5_0\">CSP 5.0<\/a>, \u0432 \u043a\u043e\u0442\u043e\u0440\u043e\u043c \u043e\u0431\u0435\u0449\u0430\u043d\u0430 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0430 RSA \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432. \u0421\u0443\u0434\u044f \u043f\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u0438 \u043d\u0430 \u0438\u0445 \u0441\u0430\u0439\u0442\u0435, \u043f\u043e\u043a\u0430 \u043e\u043d\u0430 \u0435\u0449\u0435 \u043d\u0435 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u0446\u0438\u0440\u043e\u0432\u0430\u043d\u0430, \u043d\u043e \u043a\u043e\u0433\u0434\u0430 \u0431\u0443\u0434\u0435\u0442, \u0442\u043e \u0440\u0430\u0431\u043e\u0442\u0443 \u0441\u0438\u0441\u0442\u0435\u043c\u044b \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0449\u0443\u044e \u0438 \u0413\u041e\u0421\u0422\u043e\u0432\u044b\u0435 \u043a\u043b\u044e\u0447\u0438 \u0438 RSA, \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u043b\u043e\u0433\u0438\u0447\u043d\u0435\u0435 \u0441\u0442\u0440\u043e\u0438\u0442\u044c \u043d\u0430 \u043d\u0435\u0439.<\/p>\n<p>  <\/p>\n<h1>\u0421\u0441\u044b\u043b\u043a\u0438<\/h1>\n<p>  <\/p>\n<ol>\n<li>OpenSSL 1.0.2 <a href=\"https:\/\/www.openssl.org\/docs\/man1.0.2\/crypto\/\">ManPages<\/a>;<\/li>\n<li>\u041c\u043d\u043e\u0433\u043e\u043f\u043e\u0442\u043e\u0447\u043d\u043e\u0441\u0442\u044c \u0432 OpenSSL <a href=\"https:\/\/www.openssl.org\/docs\/faq.html#PROG1\">1<\/a> \u0438 <a href=\"https:\/\/www.openssl.org\/blog\/blog\/2017\/02\/21\/threads\/\">2<\/a>;<\/li>\n<li>\u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 <a href=\"https:\/\/github.com\/openssl\/openssl\/tree\/32f803d88ec3df7f95dfbf840c271f7438ce3357\">OpenSSL<\/a>:<br \/> \n<ol>\n<li><a href=\"https:\/\/github.com\/openssl\/openssl\/blob\/32f803d88ec3df7f95dfbf840c271f7438ce3357\/crypto\/cms\/cms_smime.c\">cms_smime.c;<\/a><\/li>\n<\/ol>\n<\/li>\n<li><a href=\"https:\/\/wiki.openssl.org\/index.php\/Libcrypto_API\">Wiki OpenSSL<\/a>;<\/li>\n<li>\u0418\u0441\u0445\u043e\u0434\u043d\u0438\u043a\u0438 mono:\n<ol>\n<li> \u043a\u043b\u0430\u0441\u0441 <a href=\"https:\/\/github.com\/mono\/mono\/blob\/776e31141400017e7262bf76d456ec07733db8a1\/mcs\/class\/Mono.Security\/Mono.Security.Cryptography\/RSAManaged.cs#L177\">RSAManaged<\/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\/423769\/\"> https:\/\/habr.com\/post\/423769\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"\n<div class=\"post__text post__text-html js-mediator-article\">\n<p>\u0412 \u043f\u0440\u0435\u0434\u044b\u0434\u0443\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0435 \u0431\u044b\u043b \u043e\u043f\u0438\u0441\u0430\u043d \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0438\u043d\u0442\u0435\u0433\u0440\u0430\u0446\u0438\u0438 \u0413\u041e\u0421\u0422\u043e\u0432\u044b\u0445 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u041a\u0440\u0438\u043f\u0442\u043e\u041f\u0440\u043e \u0441 mono. \u0412 \u044d\u0442\u043e\u0439 \u0436\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e \u043e\u0441\u0442\u0430\u043d\u043e\u0432\u0438\u043c\u0441\u044f \u043d\u0430 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 RSA \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432.<\/p>\n<p>  <\/p>\n<p>\u041c\u044b \u043f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u043b\u0438 \u043f\u0435\u0440\u0435\u043d\u043e\u0441\u0438\u0442\u044c \u043e\u0434\u043d\u0443 \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\u044b\u0445 \u043d\u0430 C# \u0432 Linux, \u0438 \u043e\u0447\u0435\u0440\u0435\u0434\u044c \u0434\u043e\u0448\u043b\u0430 \u0434\u043e \u0447\u0430\u0441\u0442\u0438 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u043e\u0439 \u0441 RSA. \u0415\u0441\u043b\u0438 \u0432 \u043f\u0440\u043e\u0448\u043b\u044b\u0439 \u0440\u0430\u0437 \u0441\u043b\u043e\u0436\u043d\u043e\u0441\u0442\u0438 \u0432 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u043b\u0435\u0433\u043a\u043e \u043e\u0431\u044a\u044f\u0441\u043d\u044f\u043b\u0438\u0441\u044c \u043d\u0430\u043b\u0438\u0447\u0438\u0435\u043c \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0434\u0432\u0443\u0445, \u0438\u0441\u0445\u043e\u0434\u043d\u043e \u043d\u0435 \u0441\u0432\u044f\u0437\u0430\u043d\u043d\u044b\u0445 \u0434\u0440\u0443\u0433 \u0441 \u0434\u0440\u0443\u0433\u043e\u043c \u0441\u0438\u0441\u0442\u0435\u043c, \u0442\u043e \u043f\u0440\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0438 \u00ab\u043e\u0431\u044b\u0447\u043d\u044b\u0445\u00bb RSA \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u0432 \u043e\u0442 mono \u044f\u0432\u043d\u043e \u043d\u0438\u043a\u0442\u043e \u043d\u0435 \u043e\u0436\u0438\u0434\u0430\u043b \u043f\u043e\u0434\u0432\u043e\u0445\u0430.<\/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-289616","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/289616","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=289616"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/289616\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=289616"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=289616"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=289616"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}