amphtml: update cache return . 403
Hi all
I had read the "https://developers.google.com/amp/cache/update-cache" and follow the example verify the data ok
vocka@lalacube:/tmp$ . openssl dgst -sha256 -signature signature2.bin -verify public-key.pem url.txt . Verified OK
Step 1. check the public key
-
https://blog.lalacube.com/.well-known/amphtml/apikey.pub <- can read the data.
-
my sample code ` php function urlsafe_b64encode($string) { $data = base64_encode($string); $data = str_replace(array(‘+’,‘/’,‘=’),array(‘-’,‘_’,‘’),$data); return $data; } $timestamp=time(); $ampBaseUrl = “https://blog-lalacube-com.cdn.ampproject.org”; //https://blog-lalacube-com.cdn.ampproject.org/c/s/blog.lalacube.com/mei/yahoo_auction_amp.html $signatureUrl = ‘/update-cache/c/s/blog.lalacube.com/mei/yahoo_auction_amp.html?amp_action=flush&_ts=’.$timestamp; // opening the private key
$pkeyid = openssl_pkey_get_private(“file://private-key.pem”); // generating the signature openssl_sign($signatureUrl, $signature, $pkeyid, OPENSSL_ALGO_SHA256); openssl_free_key($pkeyid);
$signature = urlsafe_b64encode($signature); // final url for updating $ampUrl = $ampBaseUrl.$signatureUrl.“&_url_signature=”.$signature; echo $ampUrl.“\n”; `
I found the https://stackoverflow.com/questions/46176405/amp-update-cache-request-returns-403 , it’s similar.
So how can i debug ? thank Vocka
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 51 (14 by maintainers)
I have published a composer package for clearing AMP cache
https://packagist.org/packages/ennexa/amp-update-cache
this worked for me. got it up and running relatively quickly despite never having used php
I had the same issue. my problem was:
Hope that helps!
Sorry to keep you waiting, @JoyceBabu :
/update-cache/c/www.prokerala.com/astrology/horoscope/%3fsign=leo&=1?amp_action=flush&_ts=1512564684
If this doesn’t help, please share the code you used to produce the signed url.
First of all, I determined that AMP Cache does not handle HTTP refresh correctly for update-cache verification keys: if you issue an update-cache request and then swap /.well-known/amphtml/apikey.pub with a different key, we keep using the old key material indefinitely. To make things worse, 404 responses are also cached forever 😦
I filed an internal bug report, but it might take some time for the fix to roll out to production. Meanwhile, I can flush invalid keys manually. Just send me a private message either on GitHub or on amphtml.slack.com. Apologies for not discovering this sooner.
Specifically for @advgiarc: the code at https://dpaste.de/27OM should include the leading “/” in sign_url. Everything else looks correct to me.