@@ -37,7 +37,7 @@ class ACMEv2 { // Communication with Let's Encrypt via ACME v2 protocol
3737 $ directories =array (
3838 'live ' =>'https://acme-v02.api.letsencrypt.org/directory ' ,
3939 'staging ' =>'https://acme-staging-v02.api.letsencrypt.org/directory '
40- ),$ ch =null ,$ bits ,$ sha_bits ,$ directory ,$ resources ,$ jwk_header ,$ kid_header ,$ account_key ,$ thumbprint ,$ nonce =null ;
40+ ),$ ch =null ,$ logger = true , $ bits ,$ sha_bits ,$ directory ,$ resources ,$ jwk_header ,$ kid_header ,$ account_key ,$ thumbprint ,$ nonce =null ;
4141 private $ delay_until =null ;
4242
4343 public function __construct ($ live =true ){
@@ -113,8 +113,31 @@ public function getAccountID(){
113113 return $ this ->kid_header ['kid ' ];
114114 }
115115
116+ public function setLogger ($ value =true ){
117+ switch (true ){
118+ case is_bool ($ value ):
119+ break ;
120+ case is_callable ($ value ):
121+ break ;
122+ default :
123+ throw new Exception ('setLogger: invalid value provided ' );
124+ break ;
125+ }
126+ $ this ->logger =$ value ;
127+ }
128+
116129 public function log ($ txt ){
117- error_log ($ txt );
130+ switch (true ){
131+ case $ this ->logger ===true :
132+ error_log ($ txt );
133+ break ;
134+ case $ this ->logger ===false :
135+ break ;
136+ default :
137+ $ fn =$ this ->logger ;
138+ $ fn ($ txt );
139+ break ;
140+ }
118141 }
119142
120143 protected function create_ACME_Exception ($ type ,$ detail ,$ subproblems =array ()){
@@ -286,7 +309,7 @@ private function http_request($url,$data=null){
286309 }
287310
288311 $ method =$ data ===false ?'HEAD ' :($ data ===null ?'GET ' :'POST ' );
289- $ user_agent ='ACMECert v3.2.2 (+https://github.com/skoerfgen/ACMECert) ' ;
312+ $ user_agent ='ACMECert v3.3.0 (+https://github.com/skoerfgen/ACMECert) ' ;
290313 $ header =($ data ===null ||$ data ===false )?array ():array ('Content-Type: application/jose+json ' );
291314 if ($ this ->ch ) {
292315 $ headers =array ();
0 commit comments