{"id":284553,"date":"2017-04-06T16:55:02","date_gmt":"2017-04-06T12:55:02","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=284553"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=284553","title":{"rendered":"\u041f\u0438\u0448\u0435\u043c \u00abHello, World\u00bb Telegram \u0431\u043e\u0442\u0430 \u043d\u0430 \u0421\u0438"},"content":{"rendered":"<p>\u041f\u0440\u0438\u0432\u0435\u0442 \u0432\u0441\u0435\u043c, \u043d\u0435 \u0437\u043d\u0430\u044e \u0437\u0430\u0447\u0435\u043c \u044d\u0442\u043e \u043d\u0430\u0434\u043e, \u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u043a\u043e\u043c\u0443 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f\u2026<\/p>\n<p>  <b>\u0414\u0438\u0441\u043a\u043b\u0435\u0439\u043c\u0435\u0440:<\/b> \u042f \u043d\u0438 \u0432 \u043a\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0441\u044c \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c \u0421\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u043c.<\/p>\n<p>  \u0427\u0442\u043e \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f:<\/p>\n<p>  <b>1.<\/b> \u041b\u044e\u0431\u043e\u0439 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440 \u043d\u0430 Linux, Ubuntu, Centos, MacOS\u2026 \u0441 \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u043c \u043a \u043f\u043e\u0440\u0442\u0443 443 \u0438\u043b\u0438 8443 \u0438\u0437 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430.<br \/>  <b>2.<\/b> \u041b\u044e\u0431\u043e\u0439 \u0421\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440<br \/>  <b>3.<\/b> \u0411\u0438\u0431\u0438\u043b\u0438\u043e\u0442\u0435\u043a\u0438 openssl, libssl-dev (\u00abapt-get install openssl libssl-dev\u00bb \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435, \u0434\u043b\u044f Ubuntu)<br \/>  <a name=\"habracut\"><\/a><br \/>  \u0418\u0442\u0430\u043a, \u043f\u0440\u0438\u0441\u0442\u0443\u043f\u0438\u043c\u2026<\/p>\n<p>  <b>\u041f\u0435\u0440\u0432\u043e\u0435<\/b> \u0447\u0442\u043e \u043d\u0443\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u2014 \u044d\u0442\u043e \u0441\u043e\u0437\u0434\u0430\u0442\u044c \u0431\u043e\u0442\u0430 \u0443 \u043e\u0442\u0446\u0430 \u0432\u0441\u0435\u0445 \u0431\u043e\u0442\u043e\u0432 @BotFather, \u043e\u043f\u0443\u0441\u0442\u0438\u043c \u0432\u0441\u0435 \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u0438 \u043f\u0440\u0435\u0434\u043f\u043e\u043b\u043e\u0436\u0438\u043c \u0447\u0442\u043e \u0441 \u044d\u0442\u043e\u0439 \u0437\u0430\u0434\u0430\u0447\u0435\u0439 \u0432\u0441\u0435 \u0441\u043f\u0440\u0430\u0432\u0438\u043b\u0438\u0441\u044c \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 \u0442\u043e\u043a\u0435\u043d, \u0447\u0442\u043e-\u0442\u043e \u0432\u0440\u043e\u0434\u0435:<br \/>  373288854:AAHHT77v5_ZNEM\u0443\u04414bfn\u0420\u0429o6dxiMeeEwgwJ<\/p>\n<p>  \u0414\u0430\u043b\u0435\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c ssl \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442, \u0434\u043b\u044f \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0438 WebHook. \u041a\u043e\u043c\u0430\u043d\u0434\u0430 \u0432\u044b\u0433\u043b\u044f\u0434\u0438\u0442 \u043f\u0440\u0438\u043c\u0435\u0440\u043d\u043e \u0442\u0430\u043a: <\/p>\n<pre><code>openssl req -newkey rsa:2048 -sha256 -nodes -keyout private.key -x509 -days 365 -out public.pem<\/code><\/pre>\n<p>  \u0423\u043f\u0430\u043a\u0443\u0435\u043c \u043a\u043b\u044e\u0447 \u0438 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u044b\u0439 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442 \u0432 \u043e\u0434\u0438\u043d \u0444\u0430\u0439\u043b:<\/p>\n<pre><code>cat private.key public.pem &gt; cert.pem<\/code><\/pre>\n<p>  \u0423\u0441\u0442\u0430\u043d\u0430\u0432\u043b\u0438\u0432\u0430\u0435\u043c WebHook:<\/p>\n<pre><code>curl -F&quot;url=https:\/\/\u0412\u0410\u0428_IP:\u041f\u041e\u0420\u0422(\u043b\u0438\u0431\u043e 443, \u043b\u0438\u0431\u043e 8443)\/\u041b\u042e\u0411\u041e\u0419_URI(\u043c\u043e\u0436\u043d\u043e \u0438 \u0431\u0435\u0437 \u043d\u0435\u0433\u043e, \u044f \u0431\u0443\u0434\u0443 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0442\u043e\u043a\u0435\u043d)\/&quot; -F&quot;certificate=@public.pem&quot; https:\/\/api.telegram.org\/bot\u0422\u041e\u041a\u0415\u041d\/setWebhook\/<\/code><\/pre>\n<p>  \u0414\u043e\u043b\u0436\u0435\u043d \u043f\u0440\u0438\u0439\u0442\u0438 JSON \u043e\u0442\u0432\u0435\u0442 \u0447\u0442\u043e-\u0442\u043e \u0442\u0438\u043f\u0430 success:true&#8230;, \u0435\u0441\u043b\u0438 \u043d\u0435\u0442 \u0442\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u044c\u0442\u0435 \u0432\u0441\u0435 \u0438 \u043f\u043e\u043f\u0440\u043e\u0431\u0443\u0439\u0442\u0435 \u0435\u0449\u0435 \u0440\u0430\u0437.<\/p>\n<p>  \u041f\u0440\u0438\u0441\u0442\u0443\u043f\u0430\u0435\u043c \u043a \u0441\u0430\u043c\u043e\u043c\u0443 \u0438\u043d\u0442\u0435\u0440\u0435\u0441\u043d\u043e\u043c\u0443:<\/p>\n<p>  \u0421\u043e\u0437\u0434\u0430\u0435\u043c \u0444\u0430\u0439\u043b main.c \u0438 \u043e\u0442\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0435\u0433\u043e \u0432 \u043b\u044e\u0431\u043e\u043c \u0440\u0435\u0434\u0430\u043a\u0442\u043e\u0440\u0435. \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043d\u0435\u043e\u0431\u0445\u043e\u0434\u0438\u043c\u044b\u0435 \u0431\u0438\u0431\u043b\u0438\u043e\u0442\u0435\u043a\u0438: <\/p>\n<pre><code class=\"cpp\">#include &lt;stdio.h&gt; #include &lt;openssl\/bio.h&gt; #include &lt;openssl\/ssl.h&gt; #include &lt;unistd.h&gt; #include &lt;openssl\/err.h&gt; #include &lt;netinet\/in.h&gt; #include &lt;sys\/socket.h&gt; #include &lt;sys\/types.h&gt; #include &lt;resolv.h&gt; #include &lt;netdb.h&gt; <\/code><\/pre>\n<p>  \u0424\u0443\u043d\u043a\u0446\u0438\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u0438 \u0441\u043e\u043a\u0435\u0442\u0430:<\/p>\n<pre><code class=\"cpp\">int InitializeSocket(int port) {     int sd = socket(AF_INET, SOCK_STREAM, 0);      if (sd &lt; 0) exit(-1);     struct sockaddr_in s_addr;     s_addr.sin_family = AF_INET;     s_addr.sin_addr.s_addr = INADDR_ANY;     s_addr.sin_port = htons(port);     if (bind(sd, (struct sockaddr *)&s_addr, sizeof(s_addr)) &lt; 0) {         printf(&quot;Binding Error!\\n&quot;);         exit(-3);     }     return sd; } <\/code><\/pre>\n<p>  \u0412\u043a\u043b\u044e\u0447\u0430\u0435\u043c SSL\/TLS:<\/p>\n<pre><code class=\"cpp\">SSL_CTX * InitializeSSL(char[] certificate) {     OpenSSL_add_all_algorithms();     SSL_load_error_strings();     SSL_library_init();     SSL_CTX * sslctx = SSL_CTX_new(TLSv1_2_server_method());     if (SSL_CTX_use_certificate_file(sslctx, certificate , SSL_FILETYPE_PEM) &lt;= 0) {         exit(-2);     }     if (SSL_CTX_use_PrivateKey_file(sslctx,  certificate, SSL_FILETYPE_PEM) &lt;= 0) {         exit(-2);     }     if (!SSL_CTX_check_private_key(sslctx)) {        exit(-2);     }     return sslctx; } <\/code><\/pre>\n<p>  \u0421\u043e\u0431\u0441\u0442\u0432\u0435\u043d\u043d\u043e \u0441\u0430\u043c main():<\/p>\n<pre><code class=\"cpp\">int main() {     SSL_CTX * sslctx = InitializeSSL(&quot;cert.pem&quot;); \/\/\u0421\u043e\u0437\u0434\u0430\u043d\u043d\u044b\u0439 \u043d\u0430\u043c\u0438 \u0444\u0430\u0439\u043b \u0438\u0437 \u043f\u0440\u0438\u0432\u0430\u0442\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430 \u0438 \u043f\u0443\u0431\u043b\u0438\u0447\u043d\u043e\u0433\u043e \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u0430     int sd = InitializeSocket(8443);  \/\/\u041f\u043e\u0440\u0442 \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u0432\u044b \u0443\u043a\u0430\u0437\u0430\u043b\u0438 \u043f\u0440\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 WebHook     listen(sd, 5); \/\/\u0421\u043b\u0443\u0448\u0430\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043d\u0430 \u0441\u043e\u0437\u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043e\u043a\u0435\u0442\u0435     while (1) { \/\/\u0417\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0431\u0435\u0441\u043a\u043e\u043d\u0435\u0447\u043d\u044b\u0439 \u0446\u0438\u043a\u043b         int client = accept(sd, NULL, NULL) \/\/\u0444\u0443\u043d\u043a\u0446\u0438\u044f accept \u0436\u0434\u0435\u0442 \u043d\u043e\u0432\u043e\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440\u043e\u0432 \u043f\u0440\u0438\u043d\u0438\u043c\u0430\u0435\u0442 \u0441\u043e\u043a\u0435\u0442, \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u0443 sockaddr, \u0438 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0430 \u0440\u0430\u0437\u043c\u0435\u0440 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u0443\u043a\u0442\u0443\u0440\u044b \u0438 \u0437\u0430\u043f\u0438\u0441\u044b\u0432\u0430\u0435\u0442 \u0442\u0443\u0434\u0430 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f, \u0442\u0430\u043a \u043a\u0430\u043a \u043d\u0430\u043c \u043d\u0435\u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u043f\u043e\u0434\u0440\u043e\u0431\u043d\u043e\u0441\u0442\u0438 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043c NULL, \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0441\u0435\u0442\u0435\u0432\u043e\u0439 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440.          SSL * ssl = SSL_new(sslctx); \/\/C\u043e\u0437\u0434\u0430\u0435\u043c ssl \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440         SSL_set_fd(ssl, client); \/\/\u041f\u0435\u0440\u0435\u043a\u043b\u044e\u0447\u0430\u0435\u043c \u043e\u0431\u044b\u0447\u043d\u044b\u0439 \u0434\u0435\u0441\u043a\u0440\u0438\u043f\u0442\u043e\u0440 \u043d\u0430 \u0437\u0430\u0449\u0438\u0449\u0435\u043d\u043d\u044b\u0439          if (SSL_accept(ssl) &lt;= 0) { \/\/\u041f\u044b\u0442\u0430\u0435\u043c\u0441\u044f \u043f\u0440\u0438\u043d\u044f\u0442\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435, \u0435\u0441\u043b\u0438 \u043e\u0448\u0438\u0431\u043a\u0430 \u0442\u043e \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a \u043d\u0430\u0447\u0430\u043b\u0443 \u0446\u0438\u043a\u043b\u0430             SSL_clear(ssl);             close(newsd);             continue;         }         \/\/\u0414\u043b\u044f \u0443\u0432\u0435\u043b\u0438\u0447\u0435\u043d\u0438\u044f \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0431\u0443\u0434\u0435\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c fork() \u0438 \u043e\u0431\u0440\u0430\u0431\u0430\u0442\u044b\u0432\u0430\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 \u0432 \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435, \u0430 \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u0441\u043a\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441 \u0432\u0435\u0440\u043d\u0435\u043c \u043a \u043e\u0436\u0438\u0434\u0430\u043d\u0438\u044e \u043d\u043e\u0432\u044b\u0445 \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439      int pid = fork();         if (pid != 0) { \/\/\u0415\u0441\u043b\u0438 \u044d\u0442\u043e \u0440\u043e\u0434\u0438\u0442\u0435\u043b\u044c, \u0442\u043e \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438 \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a \u043d\u0430\u0447\u0430\u043b\u0443 \u0446\u0438\u043a\u043b\u0430             SSL_clear(ssl);             close(newsd);             continue;         }     \/\/\u0414\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0438\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442\u044c \u0432 \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u043c \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0435    \/\/\u041e\u043f\u0438\u0448\u0443 \u0438\u0445 \u0434\u0430\u043b\u044c\u0448\u0435 \u043f\u043e\u0441\u043b\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u0439....     exit(0); \/\/\u0417\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u043c \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441     } } <\/code><\/pre>\n<p>  \u0422\u0430\u043a \u043a\u0430\u043a Telegram \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442 HTTP \u043f\u0440\u043e\u0442\u043e\u043a\u043e\u043b \u043f\u043e\u044f\u0441\u043d\u044e \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u043c\u043e\u043c\u0435\u043d\u0442\u044b:<\/p>\n<p>  \u041b\u044e\u0431\u043e\u0439 HTTP \u0437\u0430\u043f\u0440\u043e\u0441 \u0441\u043e\u0441\u0442\u043e\u0438\u0442 \u0438\u0437 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u0432 \u043e\u0442\u0434\u0435\u043b\u0435\u043d\u043d\u044b\u0445 \u043c\u0435\u0436\u0434\u0443 \u0441\u043e\u0431\u043e\u0439 &quot;\\r\\n&quot;, \u0438 \u0442\u0435\u043b\u0430 \u043e\u0442\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u043e\u0442 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u0432 &quot;\\r\\n\\r\\n&quot;, \u043c\u043e\u0436\u0435\u0442 \u0431\u044b\u0442\u044c \u043f\u0443\u0441\u0442\u044b\u043c, \u043d\u043e \u0440\u0430\u0437\u0434\u0435\u043b\u0438\u0442\u0435\u043b\u044c &quot;\\r\\n\\r\\n&quot; \u043f\u0440\u0438\u0441\u0443\u0442\u0441\u0442\u0432\u0443\u0435\u0442 \u0432\u0441\u0435\u0433\u0434\u0430. \u0417\u0430\u043f\u0440\u043e\u0441\u044b \u043e\u0442 Telegram \u0431\u0443\u0434\u0443\u0442 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434\u043e\u043c POST, \u0442\u0435\u043b\u043e \u0431\u0443\u0434\u0435\u0442 \u0432 \u0444\u043e\u0440\u043c\u0430\u0442\u0435 JSON.<\/p>\n<p>  \u041f\u0440\u0438\u043c\u0435\u0440 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u043f\u043e\u0445\u043e\u0436\u0435\u0433\u043e \u043d\u0430 Telegram:<\/p>\n<pre><code>POST \/(URI \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 WebHook) HTTP\/1.1\\r\\n ....\u041d\u0435\u0432\u0430\u0436\u043d\u044b\u0435 \u0434\u043b\u044f \u043d\u0430\u0441 \u043f\u043e\u043b\u044f \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u0432 Content-Type: application\/json\\r\\n (\u0422\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445 \u0432 \u0442\u0435\u043b\u0435) Content-Length: 256\\r\\n (\u0420\u0430\u0437\u043c\u0435\u0440 \u0442\u0435\u043b\u0430 \u0432 \u0431\u0430\u0439\u0442\u0430\u0445, \u0446\u0435\u043b\u043e\u0435 \u0447\u0438\u0441\u043b\u043e) ....\/r\/n\/r\/n Json \u0442\u0435\u043b\u043e <\/code><\/pre>\n<p>  \u041f\u0440\u0438 \u043a\u0430\u0436\u0434\u043e\u0439 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0435 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u043e\u043c \u0431\u043e\u0442\u0443 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u0441\u0435\u0440\u0432\u0435\u0440 \u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c\u0430 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0441\u044b\u043b\u0430\u0442\u044c \u043f\u043e\u0434\u043e\u0431\u043d\u044b\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430\u0448\u0435\u043c\u0443 \u0441\u0435\u0440\u0432\u0435\u0440\u0443. \u0412 \u043e\u0431\u0449\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430 \u043d\u0438\u0445 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u043d\u0435 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u043d\u043e \u0432 \u0441\u043b\u0443\u0447\u0430\u0435 \u0441 Telegram \u2014 \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e, \u0438\u043d\u0430\u0447\u0435 \u043e\u043d \u0431\u0443\u0434\u0435\u0442 \u0446\u0438\u043a\u043b\u0438\u0447\u043d\u043e \u043f\u043e\u0441\u044b\u043b\u0430\u0442\u044c \u043e\u0434\u0438\u043d \u0438 \u0442\u043e\u0442 \u0436\u0435 \u0437\u0430\u043f\u0440\u043e\u0441.<\/p>\n<p>  \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043c \u043a\u043e\u0440\u043e\u0442\u043a\u0438\u0439 HTTP response:<\/p>\n<pre><code>HTTP\/1.1 200 OK\\r\\n Connection: close\\r\\n\\r\\n <\/code><\/pre>\n<p>  \u042d\u0442\u0438\u0445 \u0434\u0432\u0443\u0445 \u043f\u043e\u043b\u0435\u0439 \u0434\u043e\u0441\u0442\u0430\u0442\u043e\u0447\u043d\u043e \u0447\u0442\u043e \u0431\u044b \u0441\u043a\u0430\u0437\u0430\u0442\u044c \u0441\u0435\u0440\u0432\u0435\u0440\u0443 Telegram \u0447\u0442\u043e \u0432\u0441\u0435 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e, \u043e\u0442\u0432\u0435\u0442 200 \u0438 \u043c\u043e\u0436\u043d\u043e \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0442\u044c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435<\/p>\n<p>  \u041f\u0440\u043e\u0434\u043e\u043b\u0436\u0430\u0435\u043c \u043f\u0438\u0441\u0430\u0442\u044c \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0443. \u0412\u043d\u0443\u0442\u0440\u0438 \u0446\u0438\u043a\u043b\u0430 \u043f\u043e\u0441\u043b\u0435 \u0441\u043e\u0437\u0434\u0430\u043d\u0438\u044f \u0434\u043e\u0447\u0435\u0440\u043d\u0435\u0433\u043e \u043f\u0440\u043e\u0446\u0435\u0441\u0441\u0430\u2026<\/p>\n<pre><code class=\"cpp\">char[] response = &quot;HTTP\/1.1 200 OK\\r\\nConnection: close\\r\\n\\r\\n&quot;; \/\/\u041d\u0430\u0448 HTTP response char header[1024]; bzero(header,1024); \/\/\u0412\u044b\u0434\u0435\u043b\u0438\u043b\u0438 \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u043b\u044f \u0437\u0430\u043f\u0438\u0441\u0438 \u0432 \u043d\u0435\u0433\u043e \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u043e\u0432 \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0438 \u043d\u0430 \u0432\u0441\u044f\u043a\u0438\u0439 \u0441\u043b\u0443\u0447\u0430\u0439 \u0437\u0430\u043d\u0443\u043b\u0438\u043b\u0438 \u0442\u0430\u043c \u0432\u0441\u0435 \u0437\u0430\u043f\u0438\u0441\u0438. int s = 0; int n = 0; while (strcmp(header + s - strlen(&quot;\\r\\n\\r\\n&quot;), &quot;\\r\\n\\r\\n&quot;) != 0) { \/\/strcmp \u0421\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u0442 \u0434\u0432\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 \u0438 \u0435\u0441\u043b\u0438 \u043e\u043d\u0438 \u0440\u0430\u0432\u043d\u044b \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 0, \u0432 \u043d\u0430\u0448\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u0441\u0440\u0430\u0432\u043d\u0438\u0432\u0430\u0435\u043c \u043f\u043e\u0441\u043b\u0435\u0434\u043d\u0438\u0435 strlen(&quot;\\r\\n\\r\\n&quot;) \u0431\u0430\u0439\u0442 \u0441 &quot;\\r\\n\\r\\n&quot;, \u0442\u043e \u0435\u0441\u0442\u044c \u0438\u0449\u0435\u043c \u043a\u043e\u043d\u0435\u0446 \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0430     n = SSL_read(ssl,header+s,1); \/\/\u0421\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e \u043e\u0434\u043d\u043e\u043c\u0443 \u0431\u0430\u0439\u0442\u0443 \u0432 header + s, s - \u043e\u0431\u0449\u0435\u0435 \u043a\u043e\u043b-\u0432\u043e \u0441\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0445 \u0431\u0430\u0439\u0442     s += n; \/\/n - \u043a\u043e\u043b-\u0432\u043e \u0441\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0445 \u0431\u0430\u0439\u0442 \u0437\u0430 \u0440\u0430\u0437 } \/\/\u0412\u0441\u0435, \u0437\u0430\u0433\u043e\u043b\u043e\u0432\u043a\u0438 \u0441\u0447\u0438\u0442\u0430\u043d\u044b, \u0442\u0435\u043f\u0435\u0440\u044c \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u0442\u044c \u043c\u0435\u0442\u043e\u0434, uri, content-type \u0438 \u0432\u044b\u0442\u0430\u0449\u0438\u0442\u044c content-length \u0437\u0430\u043f\u0440\u043e\u0441\u0430. if (strstr(header,&quot;POST \/(URI \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u044b\u0439 \u043f\u0440\u0438 \u0443\u0441\u0442\u0430\u043d\u043e\u0432\u043a\u0435 WebHook) HTTP\/1.1\\r\\n&quot;) == NULL) { \/\/\u0418\u0449\u0435\u043c \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0441\u0442\u0440\u043e\u043a\u0438 POST .... \u0432 header, \u0435\u0441\u043b\u0438 \u0435\u0433\u043e \u043d\u0435\u0442 \u0442\u043e \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442\u0441\u044f NULL, \u0437\u043d\u0430\u0447\u0438\u0442 \u043f\u0440\u0438\u0448\u0435\u043b \u043d\u0435\u0432\u0435\u0440\u043d\u044b\u0439 \u0437\u0430\u043f\u0440\u043e\u0441, \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u0438 \u0437\u0430\u0432\u0435\u0440\u0448\u0430\u0435\u043c \u0434\u043e\u0447\u0435\u0440\u043d\u0438\u0439 \u043f\u0440\u043e\u0446\u0435\u0441\u0441             SSL_clear(ssl);             close(client);             exit(0); } \/\/\u0422\u0430\u043a\u0436\u0435 \u043f\u0440\u043e\u0432\u0435\u0440\u0438\u043c \u0442\u0438\u043f \u0434\u0430\u043d\u043d\u044b\u0445, \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u044b\u0442\u044c application\/json;        if (strstr(header, &quot;Content-Type: application\/json&quot;) == NULL) {             SSL_clear(ssl);             close(client);             exit(0);         } \/\/\u0415\u0441\u043b\u0438 \u0432\u0441\u0435 \u043d\u043e\u0440\u043c\u0430\u043b\u044c\u043d\u043e, \u0442\u043e \u0443\u0437\u043d\u0430\u0435\u043c \u0440\u0430\u0437\u043c\u0435\u0440 \u0442\u0435\u043b\u0430 int len = atoi(strstr(header, &quot;Content-Length: &quot;) + strlen(&quot;Content-Length: &quot;)); \/\/strstr \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u0443\u043a\u0430\u0437\u0430\u0442\u0435\u043b\u044c \u043d\u0435 \u043f\u0435\u0440\u0432\u043e\u0435 \u0432\u0445\u043e\u0436\u0434\u0435\u043d\u0438\u0435 \u0443\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438, \u0442\u043e \u0435\u0441\u0442\u044c \u043d\u0430 &quot;Content-Length: &quot;, \u0430 \u043a\u043e\u043b-\u0432\u043e \u0431\u0430\u0439\u0442 \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043e \u0434\u0430\u043b\u044c\u0448\u0435 \u043f\u043e\u0441\u043b\u0435 \u044d\u0442\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u043f\u0440\u0438\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0434\u043b\u0438\u043d\u0443 \u0441\u0442\u0440\u043e\u043a\u0438 &quot;Content-Length: &quot; \u0438 \u043f\u0440\u0438\u0432\u043e\u0434\u0438\u043c \u0441\u0442\u0440\u043e\u043a\u0443 \u043a \u0442\u0438\u043f\u0443 int \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 atoi(char *);  char body[len+2];  bzero(body, len+2); \/\/\u0421\u043e\u0437\u0434\u0430\u0435\u043c \u043c\u0430\u0441\u0441\u0438\u0432 \u0434\u043b\u044f \u0442\u0435\u043b\u0430, \u043d\u0430 \u044d\u0442\u043e\u0442 \u0440\u0430\u0437 \u043c\u044b \u0442\u043e\u0447\u043d\u043e \u0437\u043d\u0430\u0435\u043c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0431\u0430\u0439\u0442 \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f, \u043d\u043e \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u0441 \u0437\u0430\u043f\u0430\u0441\u043e\u043c, \u0434\u0430\u0431\u044b \u043d\u0435 \u043e\u043a\u0430\u0437\u0430\u043b\u043e\u0441\u044c \u0447\u0442\u043e \u0432 \u043f\u0430\u043c\u044f\u0442\u0438 \u0441\u0440\u0430\u0437\u0443 \u043f\u043e\u0441\u043b\u0435 \u043d\u0430\u0448\u0435\u0439 \u0441\u0442\u0440\u043e\u043a\u0438 \u0447\u0442\u043e-\u0442\u043e \u0437\u0430\u043f\u0438\u0441\u0430\u043d\u043e  n = 0;  s = 0;  while (len - s &gt; 0) { \/\/\u0422\u0430\u043a \u043a\u0430\u043a \u043c\u044b \u0447\u0435\u0442\u043a\u043e \u0437\u043d\u0430\u0435\u043c \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0434\u0430\u043d\u043d\u044b\u0445 \u043d\u0430\u043c \u043d\u0430\u0434\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u043f\u043e\u043a\u0430 \u043d\u0435 \u0441\u0447\u0438\u0442\u0430\u0435\u043c \u043d\u0443\u0436\u043d\u043e\u0435 \u043a\u043e\u043b-\u0432\u043e     n = SSL_read(ssl, request + s, len - s); \/\/\u041a\u043e\u043d\u0435\u0447\u043d\u043e \u043c\u043e\u0436\u043d\u043e \u0431\u044b\u043b\u043e \u0441\u0447\u0438\u0442\u0430\u0442\u044c \u0446\u0435\u043b\u0438\u043a\u043e\u043c \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435, \u043d\u043e \u0431\u044b\u0432\u0430\u044e\u0442 \u0441\u043b\u0443\u0447\u0430\u0438 \u043f\u0440\u0438 \u043f\u043b\u043e\u0445\u043e\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0438, \u0437\u0430 \u0440\u0430\u0437 \u0432\u0441\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043d\u0435 \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u044e\u0442\u0441\u044f, \u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f SSL_read \u0432\u043e\u0437\u0432\u0440\u0430\u0449\u0430\u0435\u0442 \u043a\u043e\u043b-\u0432\u043e \u0441\u0447\u0438\u0442\u0430\u043d\u043d\u044b\u0445 \u0431\u0430\u0439\u0442     s += n; } \/\/\u041d\u0430 \u044d\u0442\u043e\u043c \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u043e\u043a\u043e\u043d\u0447\u0435\u043d\u043e, \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u043c \u043d\u0430\u0448 http response \u0438 \u0437\u0430\u043a\u0440\u043e\u0435\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435 SSL_write(ssl, response, (int)strlen(response)); SSL_clear(ssl); SSL_free(ssl); close(client); \/\/\u0422\u0430\u043a \u043a\u0430\u043a \u0443 \u043d\u0430\u0441 &quot;Hello, World&quot; \u0431\u043e\u0442 \u0442\u043e \u043c\u044b \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0441\u0442\u043e \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u043d\u0430 \u043b\u044e\u0431\u043e\u0435 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 &quot;Hello, World!&quot;, \u043d\u043e \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u043e \u0437\u043d\u0430\u0442\u044c \u043a\u043e\u043c\u0443 \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435 \u0434\u043b\u044f \u044d\u0442\u043e \u0438\u0437 \u0442\u0435\u043b\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u044b \u043d\u0430\u0434\u043e \u0432\u044b\u0442\u0430\u0449\u0438\u0442\u044c \u043f\u0430\u0440\u0430\u043c\u0435\u0442\u0440 chat_id int chat_id = atoi(strstr(&quot;\\&quot;chat_id\\&quot;:&quot;) + strlen(&quot;\\&quot;chat_id\\&quot;:&quot;)); \/\/\u0422\u043e \u0436\u0435 \u0441\u0430\u043c\u043e\u0435 \u0447\u0442\u043e \u0438 \u0441 Content-Length \/\/\u041e\u0441\u0442\u0430\u043b\u043e\u0441\u044c \u0442\u043e\u043b\u044c\u043a\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u0438\u0442\u044c \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u0435, \u0434\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043b\u0443\u0447\u0448\u0435 \u0441\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u0443\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u044e SendMessage char msg[] = &quot;Hello, World!&quot;; SendMessage(chat_id, msg); \/\/\u041e\u043f\u0438\u0441\u0430\u043d\u0438\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0434\u0430\u043b\u0435\u0435 <\/code><\/pre>\n<p>  \u0414\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043d\u0430\u043c \u043f\u043e\u0447\u0442\u0438 \u0442\u0430\u043a \u0436\u0435 \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u0441\u043e\u043a\u0435\u0442 \u0438 ssl, \u043d\u043e \u0432 \u043e\u0442\u043b\u0438\u0447\u0438\u0435 \u043e\u0442 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u044f \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u043c\u044b \u043d\u0435 \u0431\u0443\u0434\u0435\u043c \u0436\u0434\u0430\u0442\u044c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u044f \u0430 \u043f\u0440\u043e\u0441\u0442\u043e \u0441\u0440\u0430\u0437\u0443 \u0431\u0443\u0434\u0435\u043c \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0434\u0430\u043d\u043d\u044b\u0435:<\/p>\n<pre><code class=\"cpp\">void SendMessage(int chat_id, char[] msg) {     int port = 443;     char host[] =  &quot;api.telegram.org&quot;; \/\/\u0410\u0434\u0440\u0435\u0441 \u0438 \u043f\u043e\u0440\u0442 \u0432\u0441\u0435\u0433\u0434\u0430 \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0435    \/\/\u0421\u043e\u0437\u0434\u0430\u0434\u0438\u043c \u0448\u0430\u0431\u043b\u043e\u043d HTTP \u0437\u0430\u043f\u0440\u043e\u0441\u0430 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f, \u0432 \u0432\u0438\u0434\u0435 \u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u043e\u0439 \u0441\u0442\u0440\u043e\u043a\u0438     char header[] = &quot;POST \/bot352115436:AAEAIEPeKdR2-SS7p9jGeksQljkNa9_Smo0\/sendMessage HTTP\/1.1\\r\\nHost: files.ctrl.uz\\r\\nContent-Type: application\/json\\r\\nContent-Length: %d\\r\\nConnection: close\\r\\n\\r\\n%s&quot;;     \/\/\u0428\u0430\u0431\u043b\u043e\u043d \u0442\u0435\u043b\u0430 \u0434\u043b\u044f \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0438 \u0441\u043e\u043e\u0431\u0449\u0435\u043d\u0438\u044f     char tpl[] = &quot;{\\&quot;chat_id\\&quot;:%d,\\&quot;text\\&quot;:\\&quot;%s\\&quot;}&quot;;     char body[strlen(tpl)+strlen(msg)+16];     bzero(body, strlen(tpl)+strlen(msg)+16);     sprintf(body,tpl,chat_id,msg); \/\/\u041a\u0430\u043a printf, \u0442\u043e\u043b\u044c\u043a\u043e \u043f\u0435\u0447\u0430\u0442\u0430\u0435\u043c \u0432 char[]      char request[strlen(header)+strlen(body)+4];     bzero(request,strlen(header)+strlen(body)+4);     sprintf(request, header, strlen(body), body);    \/\/\u041f\u043e\u0434\u0433\u043e\u0442\u043e\u0432\u0438\u043b\u0438 \u043d\u0430\u0448 \u0437\u0430\u043f\u0440\u043e\u0441, \u0442\u0435\u043f\u0435\u0440\u044c \u0441\u043e\u0437\u0434\u0430\u0435\u043c \u043f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435     struct hostent *server;      struct sockaddr_in serv_addr;     int sd;     sd = socket(AF_INET, SOCK_STREAM, 0);     if (sd &lt; 0) exit(-5);     server = gethostbyname(host); \/\/\u0414\u0430\u043d\u043d\u0430\u044f \u0444\u0443\u043d\u043a\u0446\u0438\u044f \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442 ip \u0438 \u0435\u0449\u0435 \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0434\u0430\u043d\u043d\u044b\u0435 \u043f\u043e url     if (server == NULL) exit(-6);      bzero(&serv_addr, sizeof(serv_addr));     serv_addr.sin_family = AF_INET;     serv_addr.sin_port = htons(portno);     memcpy(&serv_addr.sin_addr.s_addr,server-&gt;h_addr,server-&gt;h_length);      if (connect(sd,(struct sockaddr *)&serv_addr,sizeof(serv_addr)) &lt; 0) { exit(-6);}     SSL_CTX * sslctx = SSL_CTX_new(TLSv1_client_method());     SSL * cSSL = SSL_new(sslctx);     SSL_set_fd(cSSL, sfd);     SSL_connect(cSSL);      SSL_write(cSSL,request,(int)strlen(request)); \/\/\u041e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0435\u043c \u043d\u0430\u0448 \u0437\u0430\u043f\u0440\u043e\u0441, \u0432 \u0438\u0434\u0435\u0430\u043b\u0435 \u0435\u0433\u043e \u043d\u0430\u0434\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u044f\u0442\u044c \u0442\u0430\u043a \u0436\u0435 \u043a\u0430\u043a \u043c\u044b \u0441\u0447\u0438\u0442\u044b\u0432\u0430\u043b\u0438 \u0434\u0430\u043d\u043d\u044b\u0435, \u0442\u043e \u0435\u0441\u0442\u044c \u0441 \u043f\u0440\u043e\u0432\u0435\u0440\u043a\u043e\u0439 \u043d\u0430 \u043a\u043e\u043b-\u0432\u043e \u043e\u0442\u043f\u0440\u0430\u0432\u043b\u0435\u043d\u043d\u044b\u0445 \u0431\u0430\u0439\u0442     char str[1024];     SSL_read(cSSL, str, 1024); \/\/\u0421\u0447\u0438\u0442\u044b\u0432\u0430\u0435\u043c \u043e\u0442\u0432\u0435\u0442 \u0438 \u0437\u0430\u043a\u0440\u044b\u0432\u0430\u0435\u043c \u0441\u043e\u0435\u0434\u0438\u043d\u0435\u043d\u0438\u0435     SSL_clear(cSSL);     SSL_CTX_free(sslctx);     close(sd); } <\/code><\/pre>\n<p>  \u041d\u0430 \u044d\u0442\u043e\u043c, \u0432 \u043f\u0440\u0438\u043d\u0446\u0438\u043f\u0435 \u0432\u0441\u0435. \u0421\u043e\u0445\u0440\u0430\u043d\u044f\u0435\u043c \u0444\u0430\u0439\u043b \u0432 \u043e\u0434\u043d\u043e\u0439 \u043f\u0430\u043f\u043a\u0435 \u0441 \u0441\u0435\u0440\u0442\u0438\u0444\u0438\u043a\u0430\u0442\u043e\u043c, \u043a\u043e\u043c\u043f\u0438\u043b\u0438\u0440\u0443\u0435\u043c \u043b\u044e\u0431\u044b\u043c \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440\u043e\u043c \u0438 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c:<\/p>\n<pre><code>clang main.c -o bot -lcrypto -lssl  .\/bot<\/code><\/pre>\n<p>  <b>\u041a\u043e\u043d\u0435\u0446!<\/b><\/p>\n<p>  \u041d\u0430\u0434\u0435\u044e\u0441\u044c \u0441\u0442\u0430\u0442\u044c\u044f \u0431\u0443\u0434\u0435\u0442 \u043a\u043e\u043c\u0443-\u0442\u043e \u043f\u043e\u043b\u0435\u0437\u043d\u043e\u0439.<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:\/\/habrahabr.ru\/post\/325846\/\"> https:\/\/habrahabr.ru\/post\/325846\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u041f\u0440\u0438\u0432\u0435\u0442 \u0432\u0441\u0435\u043c, \u043d\u0435 \u0437\u043d\u0430\u044e \u0437\u0430\u0447\u0435\u043c \u044d\u0442\u043e \u043d\u0430\u0434\u043e, \u043d\u043e \u043c\u043e\u0436\u0435\u0442 \u043a\u043e\u043c\u0443 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f\u2026<\/p>\n<p>  <b>\u0414\u0438\u0441\u043a\u043b\u0435\u0439\u043c\u0435\u0440:<\/b> \u042f \u043d\u0438 \u0432 \u043a\u043e\u0435\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0435 \u044f\u0432\u043b\u044f\u044e\u0441\u044c \u043f\u0440\u043e\u0444\u0435\u0441\u0441\u0438\u043e\u043d\u0430\u043b\u044c\u043d\u044b\u043c \u0421\u0438 \u043f\u0440\u043e\u0433\u0440\u0430\u043c\u043c\u0438\u0441\u0442\u043e\u043c.<\/p>\n<p>  \u0427\u0442\u043e \u043d\u0430\u043c \u043f\u043e\u043d\u0430\u0434\u043e\u0431\u0438\u0442\u0441\u044f:<\/p>\n<p>  <b>1.<\/b> \u041b\u044e\u0431\u043e\u0439 \u043a\u043e\u043c\u043f\u044c\u044e\u0442\u0435\u0440 \u043d\u0430 Linux, Ubuntu, Centos, MacOS\u2026 \u0441 \u0434\u043e\u0441\u0442\u0443\u043f\u043e\u043c \u043a \u043f\u043e\u0440\u0442\u0443 443 \u0438\u043b\u0438 8443 \u0438\u0437 \u0438\u043d\u0442\u0435\u0440\u043d\u0435\u0442\u0430.<br \/>  <b>2.<\/b> \u041b\u044e\u0431\u043e\u0439 \u0421\u0438 \u043a\u043e\u043c\u043f\u0438\u043b\u044f\u0442\u043e\u0440<br \/>  <b>3.<\/b> \u0411\u0438\u0431\u0438\u043b\u0438\u043e\u0442\u0435\u043a\u0438 openssl, libssl-dev (\u00abapt-get install openssl libssl-dev\u00bb \u0432 \u0442\u0435\u0440\u043c\u0438\u043d\u0430\u043b\u0435, \u0434\u043b\u044f Ubuntu)  <\/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-284553","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/284553","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=284553"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/284553\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=284553"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=284553"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=284553"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}