-
Notifications
You must be signed in to change notification settings - Fork 12
/
CertificateCreateRealtime.php
63 lines (55 loc) · 1.77 KB
/
CertificateCreateRealtime.php
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
53
54
55
56
57
58
59
60
61
62
63
<?php
namespace Example;
use Domainrobot\Domainrobot;
use Domainrobot\Lib\DomainrobotAuth;
use Domainrobot\Lib\DomainrobotException;
use Domainrobot\Model\Certificate;
use Domainrobot\Model\Contact;
use Domainrobot\Model\SslContact;
use Domainrobot\Model\TimePeriod;
use Domainrobot\Model\TimeUnitConstants;
class SDKController
{
/**
* Create a certificate in realtime
*
* @return Certificate
*/
public function certificateCreateRealtime()
{
$domainrobot = new Domainrobot([
'url' => 'https://api.autodns.com/v1',
'auth' => new DomainrobotAuth([
'user' => 'username',
'password' => 'password',
'context' => 4
])
]);
try {
$certificate = new Certificate();
$certificate->setName('www.example.com');
$contact = $domainrobot->sslContact->info(234234);
$certificate->setAdminContact(new SslContact([
'id' => 234234
]));
$certificate->setTechnicalContact(new SslContact([
'id' => 234234
]));
$certificate->setProduct('SSL123');
$certificate->setLifetime(new TimePeriod([
'unit' => TimeUnitConstants::MONTH,
'period' => 12
]));
$certificate->setCsr(
'
-----BEGIN CERTIFICATE REQUEST-----
MIIC4zCCAcsCAQAwgZ0xCzAJBgNVO..............+fM+gd6K8HvPkCk6C9dQ=
-----END CERTIFICATE REQUEST-----'
);
$certificate = $domainrobot->certificate->realtime($certificate);
} catch (DomainrobotException $exception) {
return $exception->getError();
}
return $certificate;
}
}