init(); } return static::$instance; } public static function getFFI(): FFI { return static::getInstance()->getFFI(); } public static function getStdLib(): FFI { if (static::$stdLib === null) { static::$stdLib = FFI::cdef("void* malloc (size_t size);", "libc.so.6"); } return static::$stdLib; } public static function malloc(int $size): FFI\CData { return static::getStdLib()->malloc($size); } public static function consumeErrors(): array { $ffi = static::getFFI(); $errs = []; while (0 !== ($code = $ffi->ERR_get_error())) { $ptr = $ffi->ERR_error_string($code, null); $errs[] = FFI::string($ptr); } return $errs; } public static function addressOf(FFI\CData $data): int { return FFI::cast("long long", $data)->cdata; } public static $caStore = null; public static function CAStore() { if (static::$caStore === null) { static::$caStore = X509Store::default(); } return static::$caStore; } }