Completed
Pull Request — master (#8)
by John
02:04
created
src/LEConnector.php 1 patch
Indentation   +127 added lines, -127 removed lines patch added patch discarded remove patch
@@ -46,7 +46,7 @@  discard block
 block discarded – undo
46 46
 
47 47
 	public $keyChange;
48 48
 	public $newAccount;
49
-    public $newNonce;
49
+	public $newNonce;
50 50
 	public $newOrder;
51 51
 	public $revokeCert;
52 52
 
@@ -55,13 +55,13 @@  discard block
 block discarded – undo
55 55
 
56 56
 	private $log;
57 57
 
58
-    /**
59
-     * Initiates the LetsEncrypt Connector class.
60
-     *
61
-     * @param int 		$log			The level of logging. Defaults to no logging. LOG_OFF, LOG_STATUS, LOG_DEBUG accepted.
62
-     * @param string	$baseURL 		The LetsEncrypt server URL to make requests to.
63
-     * @param array		$accountKeys 	Array containing location of account keys files.
64
-     */
58
+	/**
59
+	 * Initiates the LetsEncrypt Connector class.
60
+	 *
61
+	 * @param int 		$log			The level of logging. Defaults to no logging. LOG_OFF, LOG_STATUS, LOG_DEBUG accepted.
62
+	 * @param string	$baseURL 		The LetsEncrypt server URL to make requests to.
63
+	 * @param array		$accountKeys 	Array containing location of account keys files.
64
+	 */
65 65
 	public function __construct($log, $baseURL, $accountKeys)
66 66
 	{
67 67
 		$this->baseURL = $baseURL;
@@ -71,9 +71,9 @@  discard block
 block discarded – undo
71 71
 		$this->getNewNonce();
72 72
 	}
73 73
 
74
-    /**
75
-     * Requests the LetsEncrypt Directory and stores the necessary URLs in this LetsEncrypt Connector instance.
76
-     */
74
+	/**
75
+	 * Requests the LetsEncrypt Directory and stores the necessary URLs in this LetsEncrypt Connector instance.
76
+	 */
77 77
 	private function getLEDirectory()
78 78
 	{
79 79
 		$req = $this->get('/directory');
@@ -84,42 +84,42 @@  discard block
 block discarded – undo
84 84
 		$this->revokeCert = $req['body']['revokeCert'];
85 85
 	}
86 86
 
87
-    /**
88
-     * Requests a new nonce from the LetsEncrypt server and stores it in this LetsEncrypt Connector instance.
89
-     */
87
+	/**
88
+	 * Requests a new nonce from the LetsEncrypt server and stores it in this LetsEncrypt Connector instance.
89
+	 */
90 90
 	private function getNewNonce()
91 91
 	{
92 92
 		if($this->head($this->newNonce)['status'] !== 200) throw LEConnectorException::NoNewNonceException();
93 93
 	}
94 94
 
95
-    /**
96
-     * Makes a Curl request.
97
-     *
98
-     * @param string	$method	The HTTP method to use. Accepting GET, POST and HEAD requests.
99
-     * @param string 	$URL 	The URL or partial URL to make the request to. If it is partial, the baseURL will be prepended.
100
-     * @param object 	$data  	The body to attach to a POST request. Expected as a JSON encoded string.
101
-     *
102
-     * @return array 	Returns an array with the keys 'request', 'header', 'status' and 'body'.
103
-     */
95
+	/**
96
+	 * Makes a Curl request.
97
+	 *
98
+	 * @param string	$method	The HTTP method to use. Accepting GET, POST and HEAD requests.
99
+	 * @param string 	$URL 	The URL or partial URL to make the request to. If it is partial, the baseURL will be prepended.
100
+	 * @param object 	$data  	The body to attach to a POST request. Expected as a JSON encoded string.
101
+	 *
102
+	 * @return array 	Returns an array with the keys 'request', 'header', 'status' and 'body'.
103
+	 */
104 104
 	private function request($method, $URL, $data = null)
105 105
 	{
106 106
 		if($this->accountDeactivated) throw LEConnectorException::AccountDeactivatedException();
107 107
 
108 108
 		$headers = array('Accept: application/json', 'Content-Type: application/jose+json');
109 109
 		$requestURL = preg_match('~^http~', $URL) ? $URL : $this->baseURL . $URL;
110
-        $handle = curl_init();
111
-        curl_setopt($handle, CURLOPT_URL, $requestURL);
112
-        curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
113
-        curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
114
-        curl_setopt($handle, CURLOPT_HEADER, true);
115
-
116
-        switch ($method) {
117
-            case 'GET':
118
-                break;
119
-            case 'POST':
120
-                curl_setopt($handle, CURLOPT_POST, true);
121
-                curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
122
-                break;
110
+		$handle = curl_init();
111
+		curl_setopt($handle, CURLOPT_URL, $requestURL);
112
+		curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
113
+		curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
114
+		curl_setopt($handle, CURLOPT_HEADER, true);
115
+
116
+		switch ($method) {
117
+			case 'GET':
118
+				break;
119
+			case 'POST':
120
+				curl_setopt($handle, CURLOPT_POST, true);
121
+				curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
122
+				break;
123 123
 			case 'HEAD':
124 124
 				curl_setopt($handle, CURLOPT_CUSTOMREQUEST, 'HEAD');
125 125
 				curl_setopt($handle, CURLOPT_NOBODY, true);
@@ -127,25 +127,25 @@  discard block
 block discarded – undo
127 127
 			default:
128 128
 				throw LEConnectorException::MethodNotSupportedException($method);
129 129
 				break;
130
-        }
131
-        $response = curl_exec($handle);
130
+		}
131
+		$response = curl_exec($handle);
132 132
 
133
-        if(curl_errno($handle)) {
134
-            throw LEConnectorException::CurlErrorException(curl_error($handle));
135
-        }
133
+		if(curl_errno($handle)) {
134
+			throw LEConnectorException::CurlErrorException(curl_error($handle));
135
+		}
136 136
 
137
-        $headerSize = curl_getinfo($handle, CURLINFO_HEADER_SIZE);
138
-        $statusCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
137
+		$headerSize = curl_getinfo($handle, CURLINFO_HEADER_SIZE);
138
+		$statusCode = curl_getinfo($handle, CURLINFO_HTTP_CODE);
139 139
 
140
-        $header = substr($response, 0, $headerSize);
141
-        $body = substr($response, $headerSize);
140
+		$header = substr($response, 0, $headerSize);
141
+		$body = substr($response, $headerSize);
142 142
 		$jsonbody = json_decode($body, true);
143 143
 		$jsonresponse = array(
144
-            'request' => $method . ' ' . $requestURL,
145
-            'header' => $header,
146
-            'status' => $statusCode,
147
-            'body' => $jsonbody === null ? $body : $jsonbody,
148
-        );
144
+			'request' => $method . ' ' . $requestURL,
145
+			'header' => $header,
146
+			'status' => $statusCode,
147
+			'body' => $jsonbody === null ? $body : $jsonbody,
148
+		);
149 149
 		if($this->log instanceof \Psr\Log\LoggerInterface) 
150 150
 		{
151 151
 			$this->log->debug($method . ' response received', $jsonresponse);
@@ -167,122 +167,122 @@  discard block
 block discarded – undo
167 167
 			throw LEConnectorException::InvalidResponseException($jsonresponse);
168 168
 		}
169 169
 
170
-        return $jsonresponse;
170
+		return $jsonresponse;
171 171
 	}
172 172
 
173
-    /**
174
-     * Makes a GET request.
175
-     *
176
-     * @param string	$url 	The URL or partial URL to make the request to. If it is partial, the baseURL will be prepended.
177
-     *
178
-     * @return array 	Returns an array with the keys 'request', 'header', 'status' and 'body'.
179
-     */
173
+	/**
174
+	 * Makes a GET request.
175
+	 *
176
+	 * @param string	$url 	The URL or partial URL to make the request to. If it is partial, the baseURL will be prepended.
177
+	 *
178
+	 * @return array 	Returns an array with the keys 'request', 'header', 'status' and 'body'.
179
+	 */
180 180
 	public function get($url)
181 181
 	{
182 182
 		return $this->request('GET', $url);
183 183
 	}
184 184
 
185 185
 	/**
186
-     * Makes a POST request.
187
-     *
188
-     * @param string 	$url	The URL or partial URL to make the request to. If it is partial, the baseURL will be prepended.
186
+	 * Makes a POST request.
187
+	 *
188
+	 * @param string 	$url	The URL or partial URL to make the request to. If it is partial, the baseURL will be prepended.
189 189
 	 * @param object 	$data	The body to attach to a POST request. Expected as a json string.
190
-     *
191
-     * @return array 	Returns an array with the keys 'request', 'header', 'status' and 'body'.
192
-     */
190
+	 *
191
+	 * @return array 	Returns an array with the keys 'request', 'header', 'status' and 'body'.
192
+	 */
193 193
 	public function post($url, $data = null)
194 194
 	{
195 195
 		return $this->request('POST', $url, $data);
196 196
 	}
197 197
 
198 198
 	/**
199
-     * Makes a HEAD request.
200
-     *
201
-     * @param string 	$url	The URL or partial URL to make the request to. If it is partial, the baseURL will be prepended.
202
-     *
203
-     * @return array	Returns an array with the keys 'request', 'header', 'status' and 'body'.
204
-     */
199
+	 * Makes a HEAD request.
200
+	 *
201
+	 * @param string 	$url	The URL or partial URL to make the request to. If it is partial, the baseURL will be prepended.
202
+	 *
203
+	 * @return array	Returns an array with the keys 'request', 'header', 'status' and 'body'.
204
+	 */
205 205
 	public function head($url)
206 206
 	{
207 207
 		return $this->request('HEAD', $url);
208 208
 	}
209 209
 
210
-    /**
211
-     * Generates a JSON Web Key signature to attach to the request.
212
-     *
213
-     * @param array 	$payload		The payload to add to the signature.
214
-     * @param string	$url 			The URL to use in the signature.
215
-     * @param string 	$privateKeyFile The private key to sign the request with. Defaults to 'private.pem'. Defaults to accountKeys[private_key].
216
-     *
217
-     * @return string	Returns a JSON encoded string containing the signature.
218
-     */
210
+	/**
211
+	 * Generates a JSON Web Key signature to attach to the request.
212
+	 *
213
+	 * @param array 	$payload		The payload to add to the signature.
214
+	 * @param string	$url 			The URL to use in the signature.
215
+	 * @param string 	$privateKeyFile The private key to sign the request with. Defaults to 'private.pem'. Defaults to accountKeys[private_key].
216
+	 *
217
+	 * @return string	Returns a JSON encoded string containing the signature.
218
+	 */
219 219
 	public function signRequestJWK($payload, $url, $privateKeyFile = '')
220
-    {
220
+	{
221 221
 		if($privateKeyFile == '') $privateKeyFile = $this->accountKeys['private_key'];
222 222
 		$privateKey = openssl_pkey_get_private(file_get_contents($privateKeyFile));
223
-        $details = openssl_pkey_get_details($privateKey);
224
-
225
-        $protected = array(
226
-            "alg" => "RS256",
227
-            "jwk" => array(
228
-                "kty" => "RSA",
229
-                "n" => LEFunctions::Base64UrlSafeEncode($details["rsa"]["n"]),
230
-                "e" => LEFunctions::Base64UrlSafeEncode($details["rsa"]["e"]),
231
-            ),
223
+		$details = openssl_pkey_get_details($privateKey);
224
+
225
+		$protected = array(
226
+			"alg" => "RS256",
227
+			"jwk" => array(
228
+				"kty" => "RSA",
229
+				"n" => LEFunctions::Base64UrlSafeEncode($details["rsa"]["n"]),
230
+				"e" => LEFunctions::Base64UrlSafeEncode($details["rsa"]["e"]),
231
+			),
232 232
 			"nonce" => $this->nonce,
233 233
 			"url" => $url
234
-        );
234
+		);
235 235
 
236
-        $payload64 = LEFunctions::Base64UrlSafeEncode(str_replace('\\/', '/', is_array($payload) ? json_encode($payload) : $payload));
237
-        $protected64 = LEFunctions::Base64UrlSafeEncode(json_encode($protected));
236
+		$payload64 = LEFunctions::Base64UrlSafeEncode(str_replace('\\/', '/', is_array($payload) ? json_encode($payload) : $payload));
237
+		$protected64 = LEFunctions::Base64UrlSafeEncode(json_encode($protected));
238 238
 
239
-        openssl_sign($protected64.'.'.$payload64, $signed, $privateKey, "SHA256");
240
-        $signed64 = LEFunctions::Base64UrlSafeEncode($signed);
239
+		openssl_sign($protected64.'.'.$payload64, $signed, $privateKey, "SHA256");
240
+		$signed64 = LEFunctions::Base64UrlSafeEncode($signed);
241 241
 
242
-        $data = array(
243
-            'protected' => $protected64,
244
-            'payload' => $payload64,
245
-            'signature' => $signed64
246
-        );
242
+		$data = array(
243
+			'protected' => $protected64,
244
+			'payload' => $payload64,
245
+			'signature' => $signed64
246
+		);
247 247
 
248
-        return json_encode($data);
249
-    }
248
+		return json_encode($data);
249
+	}
250 250
 
251 251
 	/**
252
-     * Generates a Key ID signature to attach to the request.
253
-     *
254
-     * @param array 	$payload		The payload to add to the signature.
252
+	 * Generates a Key ID signature to attach to the request.
253
+	 *
254
+	 * @param array 	$payload		The payload to add to the signature.
255 255
 	 * @param string	$kid			The Key ID to use in the signature.
256
-     * @param string	$url 			The URL to use in the signature.
257
-     * @param string 	$privateKeyFile The private key to sign the request with. Defaults to 'private.pem'. Defaults to accountKeys[private_key].
258
-     *
259
-     * @return string	Returns a JSON encoded string containing the signature.
260
-     */
256
+	 * @param string	$url 			The URL to use in the signature.
257
+	 * @param string 	$privateKeyFile The private key to sign the request with. Defaults to 'private.pem'. Defaults to accountKeys[private_key].
258
+	 *
259
+	 * @return string	Returns a JSON encoded string containing the signature.
260
+	 */
261 261
 	public function signRequestKid($payload, $kid, $url, $privateKeyFile = '')
262
-    {
262
+	{
263 263
 		if($privateKeyFile == '') $privateKeyFile = $this->accountKeys['private_key'];
264
-        $privateKey = openssl_pkey_get_private(file_get_contents($privateKeyFile));
265
-        $details = openssl_pkey_get_details($privateKey);
264
+		$privateKey = openssl_pkey_get_private(file_get_contents($privateKeyFile));
265
+		$details = openssl_pkey_get_details($privateKey);
266 266
 
267
-        $protected = array(
268
-            "alg" => "RS256",
269
-            "kid" => $kid,
267
+		$protected = array(
268
+			"alg" => "RS256",
269
+			"kid" => $kid,
270 270
 			"nonce" => $this->nonce,
271 271
 			"url" => $url
272
-        );
272
+		);
273 273
 
274
-        $payload64 = LEFunctions::Base64UrlSafeEncode(str_replace('\\/', '/', is_array($payload) ? json_encode($payload) : $payload));
275
-        $protected64 = LEFunctions::Base64UrlSafeEncode(json_encode($protected));
274
+		$payload64 = LEFunctions::Base64UrlSafeEncode(str_replace('\\/', '/', is_array($payload) ? json_encode($payload) : $payload));
275
+		$protected64 = LEFunctions::Base64UrlSafeEncode(json_encode($protected));
276 276
 
277
-        openssl_sign($protected64.'.'.$payload64, $signed, $privateKey, "SHA256");
278
-        $signed64 = LEFunctions::Base64UrlSafeEncode($signed);
277
+		openssl_sign($protected64.'.'.$payload64, $signed, $privateKey, "SHA256");
278
+		$signed64 = LEFunctions::Base64UrlSafeEncode($signed);
279 279
 
280
-        $data = array(
281
-            'protected' => $protected64,
282
-            'payload' => $payload64,
283
-            'signature' => $signed64
284
-        );
280
+		$data = array(
281
+			'protected' => $protected64,
282
+			'payload' => $payload64,
283
+			'signature' => $signed64
284
+		);
285 285
 
286
-        return json_encode($data);
287
-    }
286
+		return json_encode($data);
287
+	}
288 288
 }
Please login to merge, or discard this patch.
src/LEAccount.php 1 patch
Indentation   +40 added lines, -40 removed lines patch added patch discarded remove patch
@@ -52,14 +52,14 @@  discard block
 block discarded – undo
52 52
 
53 53
 	private $log;
54 54
 
55
-    /**
56
-     * Initiates the LetsEncrypt Account class.
57
-     *
58
-     * @param LEConnector	$connector 		The LetsEncrypt Connector instance to use for HTTP requests.
59
-     * @param int 			$log 			The level of logging. Defaults to no logging. LOG_OFF, LOG_STATUS, LOG_DEBUG accepted.
60
-     * @param array 		$email	 		The array of strings containing e-mail addresses. Only used when creating a new account.
61
-     * @param array 		$accountKeys 	Array containing location of account keys files.
62
-     */
55
+	/**
56
+	 * Initiates the LetsEncrypt Account class.
57
+	 *
58
+	 * @param LEConnector	$connector 		The LetsEncrypt Connector instance to use for HTTP requests.
59
+	 * @param int 			$log 			The level of logging. Defaults to no logging. LOG_OFF, LOG_STATUS, LOG_DEBUG accepted.
60
+	 * @param array 		$email	 		The array of strings containing e-mail addresses. Only used when creating a new account.
61
+	 * @param array 		$accountKeys 	Array containing location of account keys files.
62
+	 */
63 63
 	public function __construct($connector, $log, $email, $accountKeys)
64 64
 	{
65 65
 		$this->connector = $connector;
@@ -85,13 +85,13 @@  discard block
 block discarded – undo
85 85
 		$this->getLEAccountData();
86 86
 	}
87 87
 
88
-    /**
89
-     * Creates a new LetsEncrypt account.
90
-     *
91
-     * @param array 	$email 	The array of strings containing e-mail addresses.
92
-     *
93
-     * @return object	Returns the new account URL when the account was successfully created, false if not.
94
-     */
88
+	/**
89
+	 * Creates a new LetsEncrypt account.
90
+	 *
91
+	 * @param array 	$email 	The array of strings containing e-mail addresses.
92
+	 *
93
+	 * @return object	Returns the new account URL when the account was successfully created, false if not.
94
+	 */
95 95
 	private function createLEAccount($email)
96 96
 	{
97 97
 		$contact = array_map(function($addr) { return empty($addr) ? '' : (strpos($addr, 'mailto') === false ? 'mailto:' . $addr : $addr); }, $email);
@@ -105,11 +105,11 @@  discard block
 block discarded – undo
105 105
 		return false;
106 106
 	}
107 107
 
108
-    /**
109
-     * Gets the LetsEncrypt account URL associated with the stored account keys.
110
-     *
111
-     * @return object	Returns the account URL if it is found, or false when none is found.
112
-     */
108
+	/**
109
+	 * Gets the LetsEncrypt account URL associated with the stored account keys.
110
+	 *
111
+	 * @return object	Returns the account URL if it is found, or false when none is found.
112
+	 */
113 113
 	private function getLEAccount()
114 114
 	{
115 115
 		$sign = $this->connector->signRequestJWK(array('onlyReturnExisting' => true), $this->connector->newAccount);
@@ -122,9 +122,9 @@  discard block
 block discarded – undo
122 122
 		return false;
123 123
 	}
124 124
 
125
-    /**
126
-     * Gets the LetsEncrypt account data from the account URL.
127
-     */
125
+	/**
126
+	 * Gets the LetsEncrypt account data from the account URL.
127
+	 */
128 128
 	private function getLEAccountData()
129 129
 	{
130 130
 		$sign = $this->connector->signRequestKid(array('' => ''), $this->connector->accountURL, $this->connector->accountURL);
@@ -145,13 +145,13 @@  discard block
 block discarded – undo
145 145
 		}
146 146
 	}
147 147
 
148
-    /**
149
-     * Updates account data. Now just supporting new contact information.
150
-     *
151
-     * @param array 	$email	The array of strings containing e-mail adresses.
152
-     *
153
-     * @return boolean	Returns true if the update is successful, false if not.
154
-     */
148
+	/**
149
+	 * Updates account data. Now just supporting new contact information.
150
+	 *
151
+	 * @param array 	$email	The array of strings containing e-mail adresses.
152
+	 *
153
+	 * @return boolean	Returns true if the update is successful, false if not.
154
+	 */
155 155
 	public function updateAccount($email)
156 156
 	{
157 157
 		$contact = array_map(function($addr) { return empty($addr) ? '' : (strpos($addr, 'mailto') === false ? 'mailto:' . $addr : $addr); }, $email);
@@ -180,11 +180,11 @@  discard block
 block discarded – undo
180 180
 		}
181 181
 	}
182 182
 
183
-    /**
184
-     * Creates new RSA account keys and updates the keys with LetsEncrypt.
185
-     *
186
-     * @return boolean	Returns true if the update is successful, false if not.
187
-     */
183
+	/**
184
+	 * Creates new RSA account keys and updates the keys with LetsEncrypt.
185
+	 *
186
+	 * @return boolean	Returns true if the update is successful, false if not.
187
+	 */
188 188
 	public function changeAccountKeys()
189 189
 	{
190 190
 		LEFunctions::RSAgenerateKeys(null, $this->accountKeys['private_key'].'.new', $this->accountKeys['public_key'].'.new');
@@ -220,11 +220,11 @@  discard block
 block discarded – undo
220 220
 		}
221 221
 	}
222 222
 
223
-    /**
224
-     * Deactivates the LetsEncrypt account.
225
-     *
226
-     * @return boolean	Returns true if the deactivation is successful, false if not.
227
-     */
223
+	/**
224
+	 * Deactivates the LetsEncrypt account.
225
+	 *
226
+	 * @return boolean	Returns true if the deactivation is successful, false if not.
227
+	 */
228 228
 	public function deactivateAccount()
229 229
 	{
230 230
 		$sign = $this->connector->signRequestKid(array('status' => 'deactivated'), $this->connector->accountURL, $this->connector->accountURL);
Please login to merge, or discard this patch.
src/LEAuthorization.php 1 patch
Indentation   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -49,13 +49,13 @@  discard block
 block discarded – undo
49 49
 
50 50
 	private $log;
51 51
 
52
-    /**
53
-     * Initiates the LetsEncrypt Authorization class. Child of a LetsEncrypt Order instance.
54
-     *
55
-     * @param LEConnector	$connector			The LetsEncrypt Connector instance to use for HTTP requests.
56
-     * @param int 			$log 				The level of logging. Defaults to no logging. LOG_OFF, LOG_STATUS, LOG_DEBUG accepted.
57
-     * @param string 		$authorizationURL 	The URL of the authorization, given by a LetsEncrypt order request.
58
-     */
52
+	/**
53
+	 * Initiates the LetsEncrypt Authorization class. Child of a LetsEncrypt Order instance.
54
+	 *
55
+	 * @param LEConnector	$connector			The LetsEncrypt Connector instance to use for HTTP requests.
56
+	 * @param int 			$log 				The level of logging. Defaults to no logging. LOG_OFF, LOG_STATUS, LOG_DEBUG accepted.
57
+	 * @param string 		$authorizationURL 	The URL of the authorization, given by a LetsEncrypt order request.
58
+	 */
59 59
 	public function __construct($connector, $log, $authorizationURL)
60 60
 	{
61 61
 		$this->connector = $connector;
@@ -81,9 +81,9 @@  discard block
 block discarded – undo
81 81
 		}
82 82
 	}
83 83
 
84
-    /**
85
-     * Updates the data associated with the current LetsEncrypt Authorization instance.
86
-     */
84
+	/**
85
+	 * Updates the data associated with the current LetsEncrypt Authorization instance.
86
+	 */
87 87
 
88 88
 	public function updateData()
89 89
 	{
@@ -106,14 +106,14 @@  discard block
 block discarded – undo
106 106
 		}
107 107
 	}
108 108
 
109
-    /**
110
-     * Gets the challenge of the given $type for this LetsEncrypt Authorization instance. Throws a Runtime Exception if the given $type is not found in this
109
+	/**
110
+	 * Gets the challenge of the given $type for this LetsEncrypt Authorization instance. Throws a Runtime Exception if the given $type is not found in this
111 111
 	 * LetsEncrypt Authorization instance.
112
-     *
113
-     * @param int	$type 	The type of verification. Supporting LEOrder::CHALLENGE_TYPE_HTTP and LEOrder::CHALLENGE_TYPE_DNS.
114
-     *
115
-     * @return array	Returns an array with the challenge of the requested $type.
116
-     */
112
+	 *
113
+	 * @param int	$type 	The type of verification. Supporting LEOrder::CHALLENGE_TYPE_HTTP and LEOrder::CHALLENGE_TYPE_DNS.
114
+	 *
115
+	 * @return array	Returns an array with the challenge of the requested $type.
116
+	 */
117 117
 	public function getChallenge($type)
118 118
 	{
119 119
 		foreach($this->challenges as $challenge)
Please login to merge, or discard this patch.
src/LEFunctions.php 1 patch
Indentation   +78 added lines, -78 removed lines patch added patch discarded remove patch
@@ -40,14 +40,14 @@  discard block
 block discarded – undo
40 40
  */
41 41
 class LEFunctions
42 42
 {
43
-    /**
44
-     * Generates a new RSA keypair and saves both keys to a new file.
45
-     *
46
-     * @param string	$directory		The directory in which to store the new keys. If set to null or empty string - privateKeyFile and publicKeyFile will be treated as absolute paths.
47
-     * @param string	$privateKeyFile	The filename for the private key file.
48
-     * @param string	$publicKeyFile  The filename for the public key file.
49
-     * @param string	$keySize 		RSA key size, must be between 2048 and 4096 (default is 4096)
50
-     */
43
+	/**
44
+	 * Generates a new RSA keypair and saves both keys to a new file.
45
+	 *
46
+	 * @param string	$directory		The directory in which to store the new keys. If set to null or empty string - privateKeyFile and publicKeyFile will be treated as absolute paths.
47
+	 * @param string	$privateKeyFile	The filename for the private key file.
48
+	 * @param string	$publicKeyFile  The filename for the public key file.
49
+	 * @param string	$keySize 		RSA key size, must be between 2048 and 4096 (default is 4096)
50
+	 */
51 51
 	public static function RSAGenerateKeys($directory, $privateKeyFile = 'private.pem', $publicKeyFile = 'public.pem', $keySize = 4096)
52 52
 	{
53 53
 		if ($keySize < 2048 || $keySize > 4096) throw LEFunctionsException::InvalidArgumentException('RSA key size must be between 2048 and 4096.');
@@ -87,14 +87,14 @@  discard block
 block discarded – undo
87 87
 		openssl_pkey_free($res);
88 88
 	}
89 89
 
90
-    /**
91
-     * Generates a new EC prime256v1 keypair and saves both keys to a new file.
92
-     *
93
-     * @param string	$directory		The directory in which to store the new keys. If set to null or empty string - privateKeyFile and publicKeyFile will be treated as absolute paths.
94
-     * @param string	$privateKeyFile	The filename for the private key file.
95
-     * @param string	$publicKeyFile  The filename for the public key file.
96
-     * @param string	$keysize  		EC key size, possible values are 256 (prime256v1) or 384 (secp384r1), default is 256
97
-     */
90
+	/**
91
+	 * Generates a new EC prime256v1 keypair and saves both keys to a new file.
92
+	 *
93
+	 * @param string	$directory		The directory in which to store the new keys. If set to null or empty string - privateKeyFile and publicKeyFile will be treated as absolute paths.
94
+	 * @param string	$privateKeyFile	The filename for the private key file.
95
+	 * @param string	$publicKeyFile  The filename for the public key file.
96
+	 * @param string	$keysize  		EC key size, possible values are 256 (prime256v1) or 384 (secp384r1), default is 256
97
+	 */
98 98
 	public static function ECGenerateKeys($directory, $privateKeyFile = 'private.pem', $publicKeyFile = 'public.pem', $keySize = 256)
99 99
 	{
100 100
 		if (version_compare(PHP_VERSION, '7.1.0') == -1) throw LEFunctionsException::PHPVersionException();
@@ -134,43 +134,43 @@  discard block
 block discarded – undo
134 134
 
135 135
 
136 136
 
137
-    /**
138
-     * Encodes a string input to a base64 encoded string which is URL safe.
139
-     *
140
-     * @param string	$input 	The input string to encode.
141
-     *
142
-     * @return string	Returns a URL safe base64 encoded string.
143
-     */
137
+	/**
138
+	 * Encodes a string input to a base64 encoded string which is URL safe.
139
+	 *
140
+	 * @param string	$input 	The input string to encode.
141
+	 *
142
+	 * @return string	Returns a URL safe base64 encoded string.
143
+	 */
144 144
 	public static function Base64UrlSafeEncode($input)
145
-    {
146
-        return str_replace('=', '', strtr(base64_encode($input), '+/', '-_'));
147
-    }
145
+	{
146
+		return str_replace('=', '', strtr(base64_encode($input), '+/', '-_'));
147
+	}
148 148
 
149
-    /**
150
-     * Decodes a string that is URL safe base64 encoded.
151
-     *
152
-     * @param string	$input	The encoded input string to decode.
153
-     *
154
-     * @return string	Returns the decoded input string.
155
-     */
156
-    public static function Base64UrlSafeDecode($input)
157
-    {
158
-        $remainder = strlen($input) % 4;
159
-        if ($remainder) {
160
-            $padlen = 4 - $remainder;
161
-            $input .= str_repeat('=', $padlen);
162
-        }
163
-        return base64_decode(strtr($input, '-_', '+/'));
164
-    }
149
+	/**
150
+	 * Decodes a string that is URL safe base64 encoded.
151
+	 *
152
+	 * @param string	$input	The encoded input string to decode.
153
+	 *
154
+	 * @return string	Returns the decoded input string.
155
+	 */
156
+	public static function Base64UrlSafeDecode($input)
157
+	{
158
+		$remainder = strlen($input) % 4;
159
+		if ($remainder) {
160
+			$padlen = 4 - $remainder;
161
+			$input .= str_repeat('=', $padlen);
162
+		}
163
+		return base64_decode(strtr($input, '-_', '+/'));
164
+	}
165 165
 
166 166
 
167 167
 
168
-    /**
169
-     * Outputs a log message.
170
-     *
171
-     * @param object	$data		The data to print.
172
-     * @param string	$function	The function name to print above. Defaults to the calling function's name from the stacktrace. (optional)
173
-     */
168
+	/**
169
+	 * Outputs a log message.
170
+	 *
171
+	 * @param object	$data		The data to print.
172
+	 * @param string	$function	The function name to print above. Defaults to the calling function's name from the stacktrace. (optional)
173
+	 */
174 174
 	public static function log($data, $function = '')
175 175
 	{
176 176
 		$e = new Exception();
@@ -192,43 +192,43 @@  discard block
 block discarded – undo
192 192
 
193 193
 
194 194
 
195
-    /**
196
-     * Makes a request to the HTTP challenge URL and checks whether the authorization is valid for the given $domain.
197
-     *
198
-     * @param string	$domain 			The domain to check the authorization for.
199
-     * @param string 	$token 				The token (filename) to request.
200
-     * @param string 	$keyAuthorization 	the keyAuthorization (file content) to compare.
201
-     *
202
-     * @return boolean	Returns true if the challenge is valid, false if not.
203
-     */
195
+	/**
196
+	 * Makes a request to the HTTP challenge URL and checks whether the authorization is valid for the given $domain.
197
+	 *
198
+	 * @param string	$domain 			The domain to check the authorization for.
199
+	 * @param string 	$token 				The token (filename) to request.
200
+	 * @param string 	$keyAuthorization 	the keyAuthorization (file content) to compare.
201
+	 *
202
+	 * @return boolean	Returns true if the challenge is valid, false if not.
203
+	 */
204 204
 	public static function checkHTTPChallenge($domain, $token, $keyAuthorization)
205 205
 	{
206 206
 		$requestURL = $domain . '/.well-known/acme-challenge/' . $token;
207 207
 		$handle = curl_init();
208
-        curl_setopt($handle, CURLOPT_URL, $requestURL);
209
-        curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
210
-        curl_setopt($handle, CURLOPT_FOLLOWLOCATION, true);
211
-        $response = trim(curl_exec($handle));
208
+		curl_setopt($handle, CURLOPT_URL, $requestURL);
209
+		curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
210
+		curl_setopt($handle, CURLOPT_FOLLOWLOCATION, true);
211
+		$response = trim(curl_exec($handle));
212 212
 
213 213
 		return (!empty($response) && $response == $keyAuthorization);
214 214
 	}
215 215
 
216
-    /**
217
-     * Checks whether the applicable DNS TXT record is a valid authorization for the given $domain.
218
-     *
219
-     * @param string	$domain 	The domain to check the authorization for.
220
-     * @param string	$DNSDigest	The digest to compare the DNS record to.
221
-     *
222
-     * @return boolean	Returns true if the challenge is valid, false if not.
223
-     */
216
+	/**
217
+	 * Checks whether the applicable DNS TXT record is a valid authorization for the given $domain.
218
+	 *
219
+	 * @param string	$domain 	The domain to check the authorization for.
220
+	 * @param string	$DNSDigest	The digest to compare the DNS record to.
221
+	 *
222
+	 * @return boolean	Returns true if the challenge is valid, false if not.
223
+	 */
224 224
 	public static function checkDNSChallenge($domain, $DNSDigest)
225 225
 	{
226 226
 		$requestURL = 'https://dns.google.com/resolve?name=_acme-challenge.' . $domain . '&type=TXT';
227 227
 		$handle = curl_init();
228
-        curl_setopt($handle, CURLOPT_URL, $requestURL);
229
-        curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
230
-        curl_setopt($handle, CURLOPT_FOLLOWLOCATION, true);
231
-        $response = json_decode(trim(curl_exec($handle)));
228
+		curl_setopt($handle, CURLOPT_URL, $requestURL);
229
+		curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
230
+		curl_setopt($handle, CURLOPT_FOLLOWLOCATION, true);
231
+		$response = json_decode(trim(curl_exec($handle)));
232 232
 		if($response->Status === 0 && isset($response->Answer))
233 233
 		{
234 234
 			foreach($response->Answer as $answer) 
@@ -242,11 +242,11 @@  discard block
 block discarded – undo
242 242
 		return false;
243 243
 	}
244 244
 
245
-    /**
246
-     * Creates a simple .htaccess file in $directory which denies from all.
247
-     *
248
-     * @param string	$directory	The directory in which to put the .htaccess file.
249
-     */
245
+	/**
246
+	 * Creates a simple .htaccess file in $directory which denies from all.
247
+	 *
248
+	 * @param string	$directory	The directory in which to put the .htaccess file.
249
+	 */
250 250
 	public static function createhtaccess($directory)
251 251
 	{
252 252
 		$htaccess = '<ifModule mod_authz_core.c>' . "\n"
Please login to merge, or discard this patch.
src/LEOrder.php 1 patch
Indentation   +88 added lines, -88 removed lines patch added patch discarded remove patch
@@ -61,18 +61,18 @@  discard block
 block discarded – undo
61 61
 	const CHALLENGE_TYPE_HTTP = 'http-01';
62 62
 	const CHALLENGE_TYPE_DNS = 'dns-01';
63 63
 
64
-    /**
65
-     * Initiates the LetsEncrypt Order class. If the base name is found in the $keysDir directory, the order data is requested. If no order was found locally, if the request is invalid or when there is a change in domain names, a new order is created.
66
-     *
67
-     * @param LEConnector	$connector			The LetsEncrypt Connector instance to use for HTTP requests.
68
-     * @param int 			$log 				The level of logging. Defaults to no logging. LOG_OFF, LOG_STATUS, LOG_DEBUG accepted.
69
-     * @param array 		$certificateKeys 	Array containing location of certificate keys files.
70
-     * @param string 		$basename 			The base name for the order. Preferable the top domain (example.org). Will be the directory in which the keys are stored. Used for the CommonName in the certificate as well.
71
-     * @param array 		$domains 			The array of strings containing the domain names on the certificate.
72
-     * @param string 		$keyType 			Type of the key we want to use for certificate. Can be provided in ALGO-SIZE format (ex. rsa-4096 or ec-256) or simple "rsa" and "ec" (using default sizes)
73
-     * @param string 		$notBefore 			A date string formatted like 0000-00-00T00:00:00Z (yyyy-mm-dd hh:mm:ss) at which the certificate becomes valid.
74
-     * @param string 		$notAfter 			A date string formatted like 0000-00-00T00:00:00Z (yyyy-mm-dd hh:mm:ss) until which the certificate is valid.
75
-     */
64
+	/**
65
+	 * Initiates the LetsEncrypt Order class. If the base name is found in the $keysDir directory, the order data is requested. If no order was found locally, if the request is invalid or when there is a change in domain names, a new order is created.
66
+	 *
67
+	 * @param LEConnector	$connector			The LetsEncrypt Connector instance to use for HTTP requests.
68
+	 * @param int 			$log 				The level of logging. Defaults to no logging. LOG_OFF, LOG_STATUS, LOG_DEBUG accepted.
69
+	 * @param array 		$certificateKeys 	Array containing location of certificate keys files.
70
+	 * @param string 		$basename 			The base name for the order. Preferable the top domain (example.org). Will be the directory in which the keys are stored. Used for the CommonName in the certificate as well.
71
+	 * @param array 		$domains 			The array of strings containing the domain names on the certificate.
72
+	 * @param string 		$keyType 			Type of the key we want to use for certificate. Can be provided in ALGO-SIZE format (ex. rsa-4096 or ec-256) or simple "rsa" and "ec" (using default sizes)
73
+	 * @param string 		$notBefore 			A date string formatted like 0000-00-00T00:00:00Z (yyyy-mm-dd hh:mm:ss) at which the certificate becomes valid.
74
+	 * @param string 		$notAfter 			A date string formatted like 0000-00-00T00:00:00Z (yyyy-mm-dd hh:mm:ss) until which the certificate is valid.
75
+	 */
76 76
 	public function __construct($connector, $log, $certificateKeys, $basename, $domains, $keyType = 'rsa-4096', $notBefore, $notAfter)
77 77
 	{
78 78
 		$this->connector = $connector;
@@ -189,13 +189,13 @@  discard block
 block discarded – undo
189 189
 		}
190 190
 	}
191 191
 
192
-    /**
193
-     * Creates a new LetsEncrypt order and fills this instance with its data. Subsequently creates a new RSA keypair for the certificate.
194
-     *
195
-     * @param array		$domains 	The array of strings containing the domain names on the certificate.
196
-     * @param string 	$notBefore 	A date string formatted like 0000-00-00T00:00:00Z (yyyy-mm-dd hh:mm:ss) at which the certificate becomes valid.
197
-     * @param string 	$notAfter 	A date string formatted like 0000-00-00T00:00:00Z (yyyy-mm-dd hh:mm:ss) until which the certificate is valid.
198
-     */
192
+	/**
193
+	 * Creates a new LetsEncrypt order and fills this instance with its data. Subsequently creates a new RSA keypair for the certificate.
194
+	 *
195
+	 * @param array		$domains 	The array of strings containing the domain names on the certificate.
196
+	 * @param string 	$notBefore 	A date string formatted like 0000-00-00T00:00:00Z (yyyy-mm-dd hh:mm:ss) at which the certificate becomes valid.
197
+	 * @param string 	$notAfter 	A date string formatted like 0000-00-00T00:00:00Z (yyyy-mm-dd hh:mm:ss) until which the certificate is valid.
198
+	 */
199 199
 	private function createOrder($domains, $notBefore, $notAfter)
200 200
 	{
201 201
 		$dns = array();
@@ -252,9 +252,9 @@  discard block
 block discarded – undo
252 252
 		}
253 253
 	}
254 254
 
255
-    /**
256
-     * Fetches the latest data concerning this LetsEncrypt Order instance and fills this instance with the new data.
257
-     */
255
+	/**
256
+	 * Fetches the latest data concerning this LetsEncrypt Order instance and fills this instance with the new data.
257
+	 */
258 258
 	private function updateOrderData()
259 259
 	{
260 260
 		$sign = $this->connector->signRequestKid('', $this->connector->accountURL, $this->orderURL);
@@ -280,8 +280,8 @@  discard block
 block discarded – undo
280 280
 	}
281 281
 
282 282
 	/**
283
-     * Fetches the latest data concerning all authorizations connected to this LetsEncrypt Order instance and creates and stores a new LetsEncrypt Authorization instance for each one.
284
-     */
283
+	 * Fetches the latest data concerning all authorizations connected to this LetsEncrypt Order instance and creates and stores a new LetsEncrypt Authorization instance for each one.
284
+	 */
285 285
 	private function updateAuthorizations()
286 286
 	{
287 287
 		$this->authorizations = array();
@@ -295,11 +295,11 @@  discard block
 block discarded – undo
295 295
 		}
296 296
 	}
297 297
 
298
-    /**
299
-     * Walks all LetsEncrypt Authorization instances and returns whether they are all valid (verified).
300
-     *
301
-     * @return boolean	Returns true if all authorizations are valid (verified), returns false if not.
302
-     */
298
+	/**
299
+	 * Walks all LetsEncrypt Authorization instances and returns whether they are all valid (verified).
300
+	 *
301
+	 * @return boolean	Returns true if all authorizations are valid (verified), returns false if not.
302
+	 */
303 303
 	public function allAuthorizationsValid()
304 304
 	{
305 305
 		if(count($this->authorizations) > 0)
@@ -313,16 +313,16 @@  discard block
 block discarded – undo
313 313
 		return false;
314 314
 	}
315 315
 
316
-    /**
317
-     * Get all pending LetsEncrypt Authorization instances and return the necessary data for verification. The data in the return object depends on the $type.
318
-     *
319
-     * @param int	$type	The type of verification to get. Supporting http-01 and dns-01. Supporting LEOrder::CHALLENGE_TYPE_HTTP and LEOrder::CHALLENGE_TYPE_DNS. Throws
316
+	/**
317
+	 * Get all pending LetsEncrypt Authorization instances and return the necessary data for verification. The data in the return object depends on the $type.
318
+	 *
319
+	 * @param int	$type	The type of verification to get. Supporting http-01 and dns-01. Supporting LEOrder::CHALLENGE_TYPE_HTTP and LEOrder::CHALLENGE_TYPE_DNS. Throws
320 320
 	 *						a Runtime Exception when requesting an unknown $type. Keep in mind a wildcard domain authorization only accepts LEOrder::CHALLENGE_TYPE_DNS.
321
-     *
322
-     * @return object	Returns an array with verification data if successful, false if not pending LetsEncrypt Authorization instances were found. The return array always
321
+	 *
322
+	 * @return object	Returns an array with verification data if successful, false if not pending LetsEncrypt Authorization instances were found. The return array always
323 323
 	 *					contains 'type' and 'identifier'. For LEOrder::CHALLENGE_TYPE_HTTP, the array contains 'filename' and 'content' for necessary the authorization file.
324 324
 	 *					For LEOrder::CHALLENGE_TYPE_DNS, the array contains 'DNSDigest', which is the content for the necessary DNS TXT entry.
325
-     */
325
+	 */
326 326
 
327 327
 	public function getPendingAuthorizations($type)
328 328
 	{
@@ -364,16 +364,16 @@  discard block
 block discarded – undo
364 364
 		return count($authorizations) > 0 ? $authorizations : false;
365 365
 	}
366 366
 
367
-    /**
368
-     * Sends a verification request for a given $identifier and $type. The function itself checks whether the verification is valid before making the request.
367
+	/**
368
+	 * Sends a verification request for a given $identifier and $type. The function itself checks whether the verification is valid before making the request.
369 369
 	 * Updates the LetsEncrypt Authorization instances after a successful verification.
370
-     *
371
-     * @param string	$identifier	The domain name to verify.
372
-     * @param int 		$type 		The type of verification. Supporting LEOrder::CHALLENGE_TYPE_HTTP and LEOrder::CHALLENGE_TYPE_DNS.
370
+	 *
371
+	 * @param string	$identifier	The domain name to verify.
372
+	 * @param int 		$type 		The type of verification. Supporting LEOrder::CHALLENGE_TYPE_HTTP and LEOrder::CHALLENGE_TYPE_DNS.
373 373
 	 * @param boolean	$localcheck	Whether to verify the authorization locally before making the authorization request to LE. Optional, default to true.
374
-     *
375
-     * @return boolean	Returns true when the verification request was successful, false if not.
376
-     */
374
+	 *
375
+	 * @return boolean	Returns true when the verification request was successful, false if not.
376
+	 */
377 377
 	public function verifyPendingOrderAuthorization($identifier, $type, $localcheck = true)
378 378
 	{
379 379
 		$privateKey = openssl_pkey_get_private(file_get_contents($this->connector->accountKeys['private_key']));
@@ -472,13 +472,13 @@  discard block
 block discarded – undo
472 472
 		return false;
473 473
 	}
474 474
 
475
-    /**
476
-     * Deactivate an LetsEncrypt Authorization instance.
477
-     *
478
-     * @param string	$identifier The domain name for which the verification should be deactivated.
479
-     *
480
-     * @return boolean	Returns true is the deactivation request was successful, false if not.
481
-     */
475
+	/**
476
+	 * Deactivate an LetsEncrypt Authorization instance.
477
+	 *
478
+	 * @param string	$identifier The domain name for which the verification should be deactivated.
479
+	 *
480
+	 * @return boolean	Returns true is the deactivation request was successful, false if not.
481
+	 */
482 482
 	public function deactivateOrderAuthorization($identifier)
483 483
 	{
484 484
 		foreach($this->authorizations as $auth)
@@ -507,12 +507,12 @@  discard block
 block discarded – undo
507 507
 		return false;
508 508
 	}
509 509
 
510
-    /**
511
-     * Generates a Certificate Signing Request for the identifiers in the current LetsEncrypt Order instance. If possible, the base name will be the certificate
510
+	/**
511
+	 * Generates a Certificate Signing Request for the identifiers in the current LetsEncrypt Order instance. If possible, the base name will be the certificate
512 512
 	 * common name and all domain names in this LetsEncrypt Order instance will be added to the Subject Alternative Names entry.
513
-     *
514
-     * @return string	Returns the generated CSR as string, unprepared for LetsEncrypt. Preparation for the request happens in finalizeOrder()
515
-     */
513
+	 *
514
+	 * @return string	Returns the generated CSR as string, unprepared for LetsEncrypt. Preparation for the request happens in finalizeOrder()
515
+	 */
516 516
 	public function generateCSR()
517 517
 	{
518 518
 		$domains = array_map(function ($dns) { return $dns['value']; }, $this->identifiers);
@@ -534,14 +534,14 @@  discard block
 block discarded – undo
534 534
 		);
535 535
 
536 536
 		$san = implode(",", array_map(function ($dns) {
537
-            return "DNS:" . $dns;
538
-        }, $domains));
539
-        $tmpConf = tmpfile();
540
-        $tmpConfMeta = stream_get_meta_data($tmpConf);
541
-        $tmpConfPath = $tmpConfMeta["uri"];
542
-
543
-        fwrite($tmpConf,
544
-            'HOME = .
537
+			return "DNS:" . $dns;
538
+		}, $domains));
539
+		$tmpConf = tmpfile();
540
+		$tmpConfMeta = stream_get_meta_data($tmpConf);
541
+		$tmpConfPath = $tmpConfMeta["uri"];
542
+
543
+		fwrite($tmpConf,
544
+			'HOME = .
545 545
 			RANDFILE = $ENV::HOME/.rnd
546 546
 			[ req ]
547 547
 			default_bits = ' . $this->keySize . '
@@ -561,13 +561,13 @@  discard block
 block discarded – undo
561 561
 		return $csr;
562 562
 	}
563 563
 
564
-    /**
565
-     * Checks, for redundancy, whether all authorizations are valid, and finalizes the order. Updates this LetsEncrypt Order instance with the new data.
566
-     *
567
-     * @param string	$csr	The Certificate Signing Request as a string. Can be a custom CSR. If empty, a CSR will be generated with the generateCSR() function.
568
-     *
569
-     * @return boolean	Returns true if the finalize request was successful, false if not.
570
-     */
564
+	/**
565
+	 * Checks, for redundancy, whether all authorizations are valid, and finalizes the order. Updates this LetsEncrypt Order instance with the new data.
566
+	 *
567
+	 * @param string	$csr	The Certificate Signing Request as a string. Can be a custom CSR. If empty, a CSR will be generated with the generateCSR() function.
568
+	 *
569
+	 * @return boolean	Returns true if the finalize request was successful, false if not.
570
+	 */
571 571
 	public function finalizeOrder($csr = '')
572 572
 	{
573 573
 		$this->updateOrderData();
@@ -617,22 +617,22 @@  discard block
 block discarded – undo
617 617
 		return false;
618 618
 	}
619 619
 
620
-    /**
621
-     * Gets whether the LetsEncrypt Order is finalized by checking whether the status is processing or valid. Keep in mind, a certificate is not yet available when the status still is processing.
622
-     *
623
-     * @return boolean	Returns true if finalized, false if not.
624
-     */
620
+	/**
621
+	 * Gets whether the LetsEncrypt Order is finalized by checking whether the status is processing or valid. Keep in mind, a certificate is not yet available when the status still is processing.
622
+	 *
623
+	 * @return boolean	Returns true if finalized, false if not.
624
+	 */
625 625
 	public function isFinalized()
626 626
 	{
627 627
 		return ($this->status == 'processing' || $this->status == 'valid');
628 628
 	}
629 629
 
630
-    /**
631
-     * Requests the certificate for this LetsEncrypt Order instance, after finalization. When the order status is still 'processing', the order will be polled max
630
+	/**
631
+	 * Requests the certificate for this LetsEncrypt Order instance, after finalization. When the order status is still 'processing', the order will be polled max
632 632
 	 * four times with five seconds in between. If the status becomes 'valid' in the meantime, the certificate will be requested. Else, the function returns false.
633
-     *
634
-     * @return boolean	Returns true if the certificate is stored successfully, false if the certificate could not be retrieved or the status remained 'processing'.
635
-     */
633
+	 *
634
+	 * @return boolean	Returns true if the certificate is stored successfully, false if the certificate could not be retrieved or the status remained 'processing'.
635
+	 */
636 636
 	public function getCertificate()
637 637
 	{
638 638
 		$polling = 0;
@@ -713,14 +713,14 @@  discard block
 block discarded – undo
713 713
 		return false;
714 714
 	}
715 715
 
716
-    /**
717
-     * Revokes the certificate in the current LetsEncrypt Order instance, if existent. Unlike stated in the ACME draft, the certificate revoke request cannot be signed
716
+	/**
717
+	 * Revokes the certificate in the current LetsEncrypt Order instance, if existent. Unlike stated in the ACME draft, the certificate revoke request cannot be signed
718 718
 	 * with the account private key, and will be signed with the certificate private key.
719
-     *
720
-     * @param int	$reason   The reason to revoke the LetsEncrypt Order instance certificate. Possible reasons can be found in section 5.3.1 of RFC5280.
721
-     *
722
-     * @return boolean	Returns true if the certificate was successfully revoked, false if not.
723
-     */
719
+	 *
720
+	 * @param int	$reason   The reason to revoke the LetsEncrypt Order instance certificate. Possible reasons can be found in section 5.3.1 of RFC5280.
721
+	 *
722
+	 * @return boolean	Returns true if the certificate was successfully revoked, false if not.
723
+	 */
724 724
 	public function revokeCertificate($reason = 0)
725 725
 	{
726 726
 		if($this->status == 'valid' || $this->status == 'ready')
Please login to merge, or discard this patch.
src/LEClient.php 1 patch
Indentation   +25 added lines, -25 removed lines patch added patch discarded remove patch
@@ -54,17 +54,17 @@  discard block
 block discarded – undo
54 54
 	const LOG_STATUS = 1;	// Logs only messages and faults.
55 55
 	const LOG_DEBUG = 2;	// Logs messages, faults and raw responses from HTTP requests.
56 56
 
57
-    /**
58
-     * Initiates the LetsEncrypt main client.
59
-     *
60
-     * @param array		$email	 			The array of strings containing e-mail addresses. Only used in this function when creating a new account.
61
-     * @param boolean	$acmeURL			ACME URL, can be string or one of predefined values: LE_STAGING or LE_PRODUCTION. Defaults to LE_STAGING.
62
-     * @param int 		$log				The level of logging. Defaults to no logging. LOG_OFF, LOG_STATUS, LOG_DEBUG accepted. Defaults to LOG_OFF. (optional)
63
-     * @param string 	$certificateKeys 	The main directory in which all keys (and certificates), including account keys, are stored. Defaults to 'keys/'. (optional)
64
-     * @param array 	$certificateKeys 	Optional array containing location of all certificate files. Required paths are public_key, private_key, order and certificate/fullchain_certificate (you can use both or only one of them)
65
-     * @param string 	$accountKeys 		The directory in which the account keys are stored. Is a subdir inside $certificateKeys. Defaults to '__account/'.(optional)
66
-     * @param array 	$accountKeys 		Optional array containing location of account private and public keys. Required paths are private_key, public_key.
67
-     */
57
+	/**
58
+	 * Initiates the LetsEncrypt main client.
59
+	 *
60
+	 * @param array		$email	 			The array of strings containing e-mail addresses. Only used in this function when creating a new account.
61
+	 * @param boolean	$acmeURL			ACME URL, can be string or one of predefined values: LE_STAGING or LE_PRODUCTION. Defaults to LE_STAGING.
62
+	 * @param int 		$log				The level of logging. Defaults to no logging. LOG_OFF, LOG_STATUS, LOG_DEBUG accepted. Defaults to LOG_OFF. (optional)
63
+	 * @param string 	$certificateKeys 	The main directory in which all keys (and certificates), including account keys, are stored. Defaults to 'keys/'. (optional)
64
+	 * @param array 	$certificateKeys 	Optional array containing location of all certificate files. Required paths are public_key, private_key, order and certificate/fullchain_certificate (you can use both or only one of them)
65
+	 * @param string 	$accountKeys 		The directory in which the account keys are stored. Is a subdir inside $certificateKeys. Defaults to '__account/'.(optional)
66
+	 * @param array 	$accountKeys 		Optional array containing location of account private and public keys. Required paths are private_key, public_key.
67
+	 */
68 68
 	public function __construct($email, $acmeURL = LEClient::LE_PRODUCTION, $log = LEClient::LOG_OFF, $certificateKeys = 'keys/', $accountKeys = '__account/')
69 69
 	{
70 70
 		$this->log = $log;
@@ -163,27 +163,27 @@  discard block
 block discarded – undo
163 163
 	}
164 164
 
165 165
 
166
-    /**
167
-     * Returns the LetsEncrypt account used in the current client.
166
+	/**
167
+	 * Returns the LetsEncrypt account used in the current client.
168 168
 	 *
169 169
 	 * @return LEAccount	The LetsEncrypt Account instance used by the client.
170
-     */
170
+	 */
171 171
 	public function getAccount()
172 172
 	{
173 173
 		return $this->account;
174 174
 	}
175 175
 
176
-    /**
177
-     * Returns a LetsEncrypt order. If an order exists, this one is returned. If not, a new order is created and returned.
178
-     *
179
-     * @param string	$basename	The base name for the order. Preferable the top domain (example.org). Will be the directory in which the keys are stored. Used for the CommonName in the certificate as well.
180
-     * @param array 	$domains 	The array of strings containing the domain names on the certificate.
181
-     * @param string 	$keyType 	Type of the key we want to use for certificate. Can be provided in ALGO-SIZE format (ex. rsa-4096 or ec-256) or simple "rsa" and "ec" (using default sizes)
182
-     * @param string 	$notBefore	A date string formatted like 0000-00-00T00:00:00Z (yyyy-mm-dd hh:mm:ss) at which the certificate becomes valid. Defaults to the moment the order is finalized. (optional)
183
-     * @param string 	$notAfter  	A date string formatted like 0000-00-00T00:00:00Z (yyyy-mm-dd hh:mm:ss) until which the certificate is valid. Defaults to 90 days past the moment the order is finalized. (optional)
184
-     *
185
-     * @return LEOrder	The LetsEncrypt Order instance which is either retrieved or created.
186
-     */
176
+	/**
177
+	 * Returns a LetsEncrypt order. If an order exists, this one is returned. If not, a new order is created and returned.
178
+	 *
179
+	 * @param string	$basename	The base name for the order. Preferable the top domain (example.org). Will be the directory in which the keys are stored. Used for the CommonName in the certificate as well.
180
+	 * @param array 	$domains 	The array of strings containing the domain names on the certificate.
181
+	 * @param string 	$keyType 	Type of the key we want to use for certificate. Can be provided in ALGO-SIZE format (ex. rsa-4096 or ec-256) or simple "rsa" and "ec" (using default sizes)
182
+	 * @param string 	$notBefore	A date string formatted like 0000-00-00T00:00:00Z (yyyy-mm-dd hh:mm:ss) at which the certificate becomes valid. Defaults to the moment the order is finalized. (optional)
183
+	 * @param string 	$notAfter  	A date string formatted like 0000-00-00T00:00:00Z (yyyy-mm-dd hh:mm:ss) until which the certificate is valid. Defaults to 90 days past the moment the order is finalized. (optional)
184
+	 *
185
+	 * @return LEOrder	The LetsEncrypt Order instance which is either retrieved or created.
186
+	 */
187 187
 	public function getOrCreateOrder($basename, $domains, $keyType = 'rsa-4096', $notBefore = '', $notAfter = '')
188 188
 	{
189 189
 		return new LEOrder($this->connector, $this->log, $this->certificateKeys, $basename, $domains, $keyType, $notBefore, $notAfter);
Please login to merge, or discard this patch.