summaryrefslogtreecommitdiffstats
path: root/library/Director/CoreBeta/StreamContextSslOptions.php
blob: d01d4a5b042d925a8de75df9f7d9fb0c2bcc9e56 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<?php

namespace Icinga\Module\Director\CoreBeta;

use Icinga\Exception\ProgrammingError;

class StreamContextSslOptions
{
    protected $options = array(
        'verify_peer' => true,
    );

    public function setCA(CA $ca)
    {
        $this->ca = $ca;
    }

    public function capturePeerCert($capture = true)
    {
        $this->options['capture_peer_cert'] = (bool) $capture;
        return $this;
    }

    public function capturePeerChain($capture = true)
    {
        $this->options['capture_peer_chain'] = (bool) $capture;
        return $this;
    }

    public function setCiphers($ciphers)
    {
        $this->options['ciphers'] = $ciphers;
        return $this;
    }

    public function setPeerName($name)
    {
        if (version_compare(PHP_VERSION, '5.6.0') >= 0) {
            $this->options['peer_name'] = $name;
            $this->options['verify_peer_name'] = true;
        } else {
            $this->options['CN_match'] = $name;
        }
        return $this;
    }

    public function getOptions()
    {
        // TODO: Fail on missing cert
        return $this->options;
    }
}