@@ -15,6 +15,8 @@ class Lescript
1515 public $ contact = array (); // optional
1616 // public $contact = array("mailto:[email protected] ", "tel:+12025551212") 1717
18+ public $ clientUserAgent = "analogic-lescript/0.3.0 " ;
19+
1820 protected $ certificatesDir ;
1921 protected $ webRootDir ;
2022
@@ -34,7 +36,7 @@ public function __construct($certificatesDir, $webRootDir, $logger = null, Clien
3436 $ this ->certificatesDir = $ certificatesDir ;
3537 $ this ->webRootDir = $ webRootDir ;
3638 $ this ->logger = $ logger ;
37- $ this ->client = $ client ? $ client : new Client ($ this ->ca );
39+ $ this ->client = $ client ? $ client : new Client ($ this ->ca , $ this -> clientUserAgent );
3840 $ this ->accountKeyPath = $ certificatesDir . '/_account/private.pem ' ;
3941 }
4042
@@ -65,6 +67,7 @@ public function initAccount()
6567
6668 public function initCommunication ()
6769 {
70+ $ this ->log ('ACME Client: ' .$ this ->clientUserAgent );
6871 $ this ->log ('Getting list of URLs for API ' );
6972
7073 $ directory = $ this ->client ->get ('/directory ' );
@@ -461,8 +464,9 @@ interface ClientInterface
461464 * Constructor
462465 *
463466 * @param string $base the ACME API base all relative requests are sent to
467+ * @param string $userAgent ACME Client User-Agent
464468 */
465- public function __construct ($ base );
469+ public function __construct ($ base, $ userAgent );
466470
467471 /**
468472 * Send a POST request
@@ -519,10 +523,12 @@ class Client implements ClientInterface
519523 protected $ lastHeader ;
520524
521525 protected $ base ;
526+ protected $ userAgent ;
522527
523- public function __construct ($ base )
528+ public function __construct ($ base, $ userAgent )
524529 {
525530 $ this ->base = $ base ;
531+ $ this ->userAgent = $ userAgent ;
526532 }
527533
528534 protected function curl ($ method , $ url , $ data = null )
@@ -533,6 +539,7 @@ protected function curl($method, $url, $data = null)
533539 curl_setopt ($ handle , CURLOPT_HTTPHEADER , $ headers );
534540 curl_setopt ($ handle , CURLOPT_RETURNTRANSFER , true );
535541 curl_setopt ($ handle , CURLOPT_HEADER , true );
542+ curl_setopt ($ handle , CURLOPT_USERAGENT , $ this ->userAgent );
536543
537544 // DO NOT DO THAT!
538545 // curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false);
0 commit comments