private function enableCrypto(RequestCycle $cycle)
{
$cryptoOptions = $this->generateCryptoOptions($cycle);
$cryptoPromise = socket\cryptoEnable($cycle->socket, $cryptoOptions);
$cryptoPromise->when(function ($error) use($cycle) {
if ($error) {
// If crypto failed we make sure the socket pool gets rid of its reference
// to this socket connection.
$this->socketPool->clear($cycle->socket);
$this->fail($cycle, $error);
} else {
$this->onCryptoCompletion($cycle);
}
});
}