@@ -21,7 +21,7 @@ public function all()
21
21
$ certificates = [];
22
22
23
23
foreach ($ this ->get ($ this ->getEndpoint ()) as $ certificate ) {
24
- $ certificates [] = str_replace ('/ ' . $ this ->client ->getApiVersion (). $ this ->getEndpoint (), '' , $ certificate );
24
+ $ certificates [] = str_replace ('/ ' . $ this ->client ->getApiVersion () . $ this ->getEndpoint (), '' , $ certificate );
25
25
}
26
26
27
27
return $ certificates ;
@@ -35,7 +35,7 @@ public function all()
35
35
*/
36
36
public function info ($ fingerprint )
37
37
{
38
- return $ this ->get ($ this ->getEndpoint (). $ fingerprint );
38
+ return $ this ->get ($ this ->getEndpoint () . $ fingerprint );
39
39
}
40
40
41
41
/**
@@ -51,14 +51,15 @@ public function info($fingerprint)
51
51
* @param string $password Password for untrusted client
52
52
* @param string $name Name for the certificate. If nothing is provided, the host in the TLS header for
53
53
* the request is used.
54
+ * @param string $token The join token to use in modern LXD (leave password as null)
54
55
* @return string fingerprint of certificate
55
56
*/
56
- public function add ($ certificate , $ password = null , $ name = null )
57
+ public function add ($ certificate , $ password = null , $ name = null , $ token = null )
57
58
{
58
59
// Convert PEM certificate to DER certificate
59
60
$ begin = "CERTIFICATE----- " ;
60
61
$ end = "-----END " ;
61
- $ pem_data = substr ($ certificate , strpos ($ certificate , $ begin )+ strlen ($ begin ));
62
+ $ pem_data = substr ($ certificate , strpos ($ certificate , $ begin ) + strlen ($ begin ));
62
63
$ pem_data = substr ($ pem_data , 0 , strpos ($ pem_data , $ end ));
63
64
$ der = base64_decode ($ pem_data );
64
65
@@ -72,11 +73,15 @@ public function add($certificate, $password = null, $name = null)
72
73
$ options ['password ' ] = $ password ;
73
74
}
74
75
76
+ if ($ token !== null ) {
77
+ $ options ['trust_token ' ] = $ token ;
78
+ }
79
+
75
80
if ($ name !== null ) {
76
81
$ options ['name ' ] = $ name ;
77
82
}
78
83
79
- $ response = $ this ->post ($ this ->getEndpoint (), $ options );
84
+ $ this ->post ($ this ->getEndpoint (), $ options );
80
85
81
86
return $ fingerprint ;
82
87
}
@@ -88,6 +93,6 @@ public function add($certificate, $password = null, $name = null)
88
93
*/
89
94
public function remove ($ fingerprint )
90
95
{
91
- $ this ->delete ($ this ->getEndpoint (). $ fingerprint );
96
+ $ this ->delete ($ this ->getEndpoint () . $ fingerprint );
92
97
}
93
98
}
0 commit comments