@@ -284,8 +284,8 @@ TSL TSL::parseTSL(const string &url, const vector<X509Cert> &certs,
284
284
THROW (" TSL %s (%llu) is expired" , territory.c_str (), tsl.sequenceNumber ());
285
285
if ((CONF (TSLOnlineDigest)) && (File::modifiedTime (path) < (time (nullptr ) - (60 * 60 * 24 ))))
286
286
{
287
- tsl.validateETag (url, timeout);
288
- File::updateModifiedTime (path, time (nullptr ));
287
+ if ( tsl.validateETag (url, timeout))
288
+ File::updateModifiedTime (path, time (nullptr ));
289
289
}
290
290
DEBUG (" TSL %s (%llu) signature is valid" , territory.c_str (), tsl.sequenceNumber ());
291
291
return tsl;
@@ -603,25 +603,22 @@ void TSL::validate(const vector<X509Cert> &certs)
603
603
* @param timeout Time to wait for downloading
604
604
* @throws Exception if ETag does not match cached ETag and TSL loading should be triggered
605
605
*/
606
- void TSL::validateETag (const string &url, int timeout)
606
+ bool TSL::validateETag (const string &url, int timeout)
607
607
{
608
608
Connect::Result r;
609
609
try {
610
610
r = Connect (url, " HEAD" , timeout).exec ({{" Accept-Encoding" , " gzip" }});
611
611
if (!r.isOK ())
612
- return ;
612
+ return false ;
613
613
} catch (const Exception &e) {
614
614
debugException (e);
615
615
DEBUG (" Failed to get ETag %s" , url.c_str ());
616
- return ;
616
+ return false ;
617
617
}
618
618
619
619
map<string,string>::const_iterator it = r.headers .find (" ETag" );
620
620
if (it == r.headers .cend ())
621
- {
622
- validateRemoteDigest (url, timeout);
623
- return ;
624
- }
621
+ return validateRemoteDigest (url, timeout);
625
622
626
623
DEBUG (" Remote ETag: %s" , it->second .c_str ());
627
624
ifstream is (File::encodeName (path + " .etag" ));
@@ -632,6 +629,7 @@ void TSL::validateETag(const string &url, int timeout)
632
629
DEBUG (" Cached ETag: %s" , etag.c_str ());
633
630
if (etag != it->second )
634
631
THROW (" Remote ETag does not match" );
632
+ return true ;
635
633
}
636
634
637
635
bool TSL::validateRemoteDigest (const string &url, int timeout)
0 commit comments