当前位置: 首页>>代码示例>>PHP>>正文


PHP EventUtil::sslRandPoll方法代码示例

本文整理汇总了PHP中EventUtil::sslRandPoll方法的典型用法代码示例。如果您正苦于以下问题:PHP EventUtil::sslRandPoll方法的具体用法?PHP EventUtil::sslRandPoll怎么用?PHP EventUtil::sslRandPoll使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EventUtil的用法示例。


在下文中一共展示了EventUtil::sslRandPoll方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: initSecureContext

 /**
  * Initialize SSL/TLS context
  * @return void
  */
 protected function initSecureContext()
 {
     if (!\EventUtil::sslRandPoll()) {
         Daemon::$process->log(get_class($this->pool) . ': EventUtil::sslRandPoll failed');
         $this->erroneous = true;
         return;
     }
     if (!FileSystem::checkFileReadable($this->certfile) || !FileSystem::checkFileReadable($this->pkfile)) {
         Daemon::log('Couldn\'t read ' . $this->certfile . ' or ' . $this->pkfile . ' file.  To generate a key' . PHP_EOL . 'and self-signed certificate, run' . PHP_EOL . '  openssl genrsa -out ' . escapeshellarg($this->pkfile) . ' 2048' . PHP_EOL . '  openssl req -new -key ' . escapeshellarg($this->pkfile) . '  -out cert.req' . PHP_EOL . '  openssl x509 -req -days 365 -in cert.req -signkey ' . escapeshellarg($this->pkfile) . '  -out ' . escapeshellarg($this->certfile));
         return;
     }
     $params = [\EventSslContext::OPT_LOCAL_CERT => $this->certfile, \EventSslContext::OPT_LOCAL_PK => $this->pkfile, \EventSslContext::OPT_VERIFY_PEER => $this->verifypeer, \EventSslContext::OPT_ALLOW_SELF_SIGNED => $this->allowselfsigned];
     if ($this->passphrase !== null) {
         $params[\EventSslContext::OPT_PASSPHRASE] = $this->passphrase;
     }
     if ($this->verifydepth !== null) {
         $params[\EventSslContext::OPT_VERIFY_DEPTH] = $this->verifydepth;
     }
     if ($this->cafile !== null) {
         $params[\EventSslContext::OPT_CA_FILE] = $this->cafile;
     }
     if ($this->tls === true) {
         $method = \EventSslContext::TLS_SERVER_METHOD;
     } elseif ($this->tls === 'v11') {
         $method = \EventSslContext::TLSv11_SERVER_METHOD;
     } elseif ($this->tls === 'v12') {
         $method = \EventSslContext::TLSv12_SERVER_METHOD;
     } elseif ($this->ssl === 'v3' || $this->ssl === true || $this->ssl === '1') {
         $method = \EventSslContext::SSLv3_SERVER_METHOD;
     } elseif ($this->ssl === 'v2') {
         $method = \EventSslContext::SSLv2_SERVER_METHOD;
     } elseif ($this->ssl === 'v23') {
         $method = \EventSslContext::SSLv23_SERVER_METHOD;
     } elseif ($this->ssl) {
         Daemon::log(get_class($this) . ': unrecognized SSL version \'' . $this->ssl . '\'');
         return;
     } else {
         return;
     }
     $this->ctx = new \EventSslContext($method, $params);
 }
开发者ID:kakserpom,项目名称:phpdaemon,代码行数:45,代码来源:Generic.php

示例2: initSSLContext

 /**
  * Initialize SSL context
  * @return object|false Context
  */
 protected function initSSLContext()
 {
     if (!\EventUtil::sslRandPoll()) {
         Daemon::$process->log(get_class($this->pool) . ': EventUtil::sslRandPoll failed');
         return false;
     }
     $params = [\EventSslContext::OPT_VERIFY_PEER => $this->verifypeer, \EventSslContext::OPT_ALLOW_SELF_SIGNED => $this->allowselfsigned];
     if ($this->certfile !== null) {
         $params[\EventSslContext::OPT_LOCAL_CERT] = $this->certfile;
     }
     if ($this->pkfile !== null) {
         $params[\EventSslContext::OPT_LOCAL_PK] = $this->pkfile;
     }
     if ($this->passphrase !== null) {
         $params[\EventSslContext::OPT_PASSPHRASE] = $this->passphrase;
     }
     $hash = igbinary_serialize($params);
     if (!self::$contextCache) {
         self::$contextCache = new CappedStorageHits(self::$contextCacheSize);
     } elseif ($ctx = self::$contextCache->getValue($hash)) {
         return $ctx;
     }
     $ctx = new \EventSslContext(\EventSslContext::SSLv3_CLIENT_METHOD, $params);
     self::$contextCache->put($hash, $ctx);
     return $ctx;
 }
开发者ID:zenus,项目名称:phpinx,代码行数:30,代码来源:Connection.php


注:本文中的EventUtil::sslRandPoll方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。