|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* eduVPN - End-user friendly VPN. |
|
5
|
|
|
* |
|
6
|
|
|
* Copyright: 2016-2017, The Commons Conservancy eduVPN Programme |
|
7
|
|
|
* SPDX-License-Identifier: AGPL-3.0+ |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace SURFnet\VPN\Server\Tests; |
|
11
|
|
|
|
|
12
|
|
|
use SURFnet\VPN\Common\Config; |
|
13
|
|
|
use SURFnet\VPN\Server\CA\CaInterface; |
|
14
|
|
|
|
|
15
|
|
|
class TestCa implements CaInterface |
|
16
|
|
|
{ |
|
17
|
|
|
/** |
|
18
|
|
|
* Generate a certificate for the VPN server. |
|
19
|
|
|
* |
|
20
|
|
|
* @param string $commonName |
|
21
|
|
|
* |
|
22
|
|
|
* @return array the certificate, key in array with keys |
|
23
|
|
|
* 'cert', 'key', 'valid_from' and 'valid_to' |
|
24
|
|
|
*/ |
|
25
|
|
View Code Duplication |
public function serverCert($commonName) |
|
26
|
|
|
{ |
|
27
|
|
|
return [ |
|
28
|
|
|
'certificate' => sprintf('ServerCert for %s', $commonName), |
|
29
|
|
|
'private_key' => sprintf('ServerCert for %s', $commonName), |
|
30
|
|
|
'valid_from' => 1234567890, |
|
31
|
|
|
'valid_to' => 2345678901, |
|
32
|
|
|
]; |
|
33
|
|
|
} |
|
34
|
|
|
|
|
35
|
|
|
/** |
|
36
|
|
|
* Generate a certificate for a VPN client. |
|
37
|
|
|
* |
|
38
|
|
|
* @param string $commonName |
|
39
|
|
|
* |
|
40
|
|
|
* @return array the certificate and key in array with keys 'cert', 'key', |
|
41
|
|
|
* 'valid_from' and 'valid_to' |
|
42
|
|
|
*/ |
|
43
|
|
View Code Duplication |
public function clientCert($commonName) |
|
44
|
|
|
{ |
|
45
|
|
|
return [ |
|
46
|
|
|
'certificate' => sprintf('ClientCert for %s', $commonName), |
|
47
|
|
|
'private_key' => sprintf('ClientKey for %s', $commonName), |
|
48
|
|
|
'valid_from' => 1234567890, |
|
49
|
|
|
'valid_to' => 2345678901, |
|
50
|
|
|
]; |
|
51
|
|
|
} |
|
52
|
|
|
|
|
53
|
|
|
/** |
|
54
|
|
|
* Get the CA root certificate. |
|
55
|
|
|
* |
|
56
|
|
|
* @return string the CA certificate in PEM format |
|
57
|
|
|
*/ |
|
58
|
|
|
public function caCert() |
|
59
|
|
|
{ |
|
60
|
|
|
return 'Ca'; |
|
61
|
|
|
} |
|
62
|
|
|
|
|
63
|
|
|
public function init(Config $config) |
|
|
|
|
|
|
64
|
|
|
{ |
|
65
|
|
|
// NOP |
|
66
|
|
|
} |
|
67
|
|
|
} |
|
68
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.