1<?php 2 3namespace Icinga\Module\Director\CoreBeta; 4 5use Icinga\Exception\ProgrammingError; 6 7class StreamContextSslOptions 8{ 9 protected $options = array( 10 'verify_peer' => true, 11 ); 12 13 public function setCA(CA $ca) 14 { 15 $this->ca = $ca; 16 } 17 18 public function capturePeerCert($capture = true) 19 { 20 $this->options['capture_peer_cert'] = (bool) $capture; 21 return $this; 22 } 23 24 public function capturePeerChain($capture = true) 25 { 26 $this->options['capture_peer_chain'] = (bool) $capture; 27 return $this; 28 } 29 30 public function setCiphers($ciphers) 31 { 32 $this->options['ciphers'] = $ciphers; 33 return $this; 34 } 35 36 public function setPeerName($name) 37 { 38 if (version_compare(PHP_VERSION, '5.6.0') >= 0) { 39 $this->options['peer_name'] = $name; 40 $this->options['verify_peer_name'] = true; 41 } else { 42 $this->options['CN_match'] = $name; 43 } 44 return $this; 45 } 46 47 public function getOptions() 48 { 49 // TODO: Fail on missing cert 50 return $this->options; 51 } 52} 53