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
$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
/to @Gregable
/cc @codewiz
Having similar issue, with no code, but using this app to test:
https://amp-cache-refresh.appspot.com/
Our public key is publicly available, any clue how to debug this issue would be great.
EDIT: we have python code that verifies our signed url, and I can share that if nesc( its also a 403).
Same here... Update cache gives me a 403: public key is available as plain text, I verified the signature with the public key (SHA256) and server times are synced. I'm using the same code as the issue author above (apart from the additional signature validation).
We're adding some debug info to the 403 responses to make debugging these issues easier in the future. Sorry about that.
I traced the above query and the internal error was "Invalid PEM key". The key decodes correctly with "openssl rsa -pubin -in apikey.pub -text -noout".
However, I noticed that blog.lalacube.com returns a 500 Internal Server Error when I try to fetch the key with curl or wget. The same url works with Chrome. So I suspect this is blocking the AMP Cache from fetching the key.
Looks like the server wants an Accept-Encoding header in the request:
curl -H 'Accept-Encoding: gzip' -i https://blog.lalacube.com/.well-known/amphtml/apikey.pub
HTTP/2 200
...
I managed get the key ingested by requesting it directly via its AMP Cache url:
https://blog-lalacube-com.cdn.ampproject.org/r/s/blog.lalacube.com/.well-known/amphtml/apikey.pub
After this, the update-cache query fails due to the expired signature, as expected.
When you get update-cache to work, try purging your key itself to make sure it gets re-ingested.
We're still having the 403 blues, appreciate any help. Here is our public key: https://minutes.advance.net/.well-known/amphtml/apikey.pub
@advgiarc The PEM key looks correct and the mime-type is text/plain. Please paste a signed update-cache request so I can see where it's being rejected.
Please also provide the code (or pseudocode) you are using to sign the url.
@codewiz
pastebin with code:
Thanks for taking a look!
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.
Great, will post you a private message when back at a computer. Thanks for investigating.
hi @codewiz
"curl -H 'Accept-Encoding: gzip' -i https://blog.lalacube.com/.well-known/amphtml/apikey.pub
HTTP/2 200" . <- Should i enable all to fetch the apikey.pub ?
I will change another key , thanks ~
@codewiz Is the issue with cached verification keys solved? Beacause I still get 403 error when trying to flush cache.
And other question: It is possible to use update-cache request to flush page that has no domain but only IP address (only for testing purposes, eg. https://24-288-88-55.cdn.ampproject.org/c/24.128.88.55/test.html )
I am also getting a 403 error while trying to flush cache
https://gist.github.com/JoyceBabu/5fa508d1ede8f6965601dfce31d1cc8f
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.
hello,
How can I fix?
404 error:
https://habervaka-com.cdn.ampproject.org/r/s/habervaka.com/.well-known/amphtml/apikey.pub
403 error:
@yumruk Your website's (https://habervaka.com) SSL certificate was revoked. (SEC_ERROR_REVOKED_CERTIFICATE). This might be the issue. ;)
@saitho To fix the problem I'm talking about 谋 have again uploaded an new SSL certificate. This is the error you mentioned.
How can I fix?
404 error:
https://habervaka-com.cdn.ampproject.org/r/s/habervaka.com/.well-known/amphtml/apikey.pub
403 error:
@yumruk The 403 error page says: "Invalid PEM key."
The key looks good to me, but there's no Content-Type header in the response. Please configure your webserver to serve the key as "text/plain".
@codewiz thanks
Hi @codewiz
I was trying to implement update cache, encountered few issues and have few questions.
when I tried updating the cache , I got 403 and the response as below (Public Key is still not made public)
HttpResponseProxy {
HTTP / 1.1 403 Forbidden[Content - Type: text / html;
charset = UTF - 8, X - Content - Type - Options: nosniff, Date: Tue, 23 Jan 2018 20: 09: 27 GMT, Server: sffe, Cache - Control: private, X - XSS - Protection: 1;
mode = block, Alt - Svc: hq = ":443";
ma = 2592000;
quic = 51303431;
quic = 51303339;
quic = 51303338;
quic = 51303337;
quic = 51303335, quic = ":443";
ma = 2592000;
v = "41,39,38,37,35", Transfer - Encoding: chunked]
}
@rnagaraj
(I am not associated with the ampproject)
We are using AMP and I can offer some insight to your questions:
1) Yes, that is the exact location your public key must live under.
2) No, if your SSL certs are all setup correctly, there is nothing else you need to do for HTTPS, as AMP and 'update-cache' ONLY work over HTTPS.
RE: the 403: if your public key is not actually public and at the .wellknown location, things will not work.
Thank you @advgiarc
Hello all and @codewiz,
I'm still getting 403 "Invalid PEM key" error message but I couldn't find any problem. Could you please control our implementation?
https://gist.github.com/ogun/61d8396eb6c58ab3c5ef71d61df89bad
Hello @codewiz
same issue. Could you please help flushing my API key?
https://studentloanhero-com.cdn.ampproject.org/r/s/studentloanhero.com/.well-known/amphtml/apikey.pub
I keep getting URL signature verification error.
Attached is generated link:
/update-cache/c/s/studentloanhero.com/featured/fico-auto-score-guide/?amp_action=flush&_ts=1523305916&_url_signature=aNi4NwXpQJwrLUCqWi-_z9WreySJ19gSvOOR8IC8GcYL2vfzDZiSxtPsTiwRb5I1qRNZrKO_EFhs0eYilM2duXZNqf__uYBvIzAlTpCWT6VESutomI1mbtIKa_1OsJPWWZPF_Madm-ma6aZQdrR2CvUXnWHqmYMve0wfwO-6BsHx0qux3jpsWgGA5t3al6UVWjOKAcaURUJYI8l_ZII_cX_is3EOrW7la3Qhel8-Kto3eEKnny2Up5VivvfhQKufDfe74k91SRR2wys26aPRr7ZsDq8pLCm5CK3f0LYFvplbx5s-OaT-8muL99alZb6z9HBX-KJt2FPES6bdEoh6Jw==
I've checked, it verifies ok with openssl locally.
I had the same issue. my problem was:
Hope that helps!
Hey @obeyer
thanks for an update. I've tried to replace '=' as well, but it didn't work.
The resulting generated link is this one:
/update-cache/c/s/studentloanhero.com/featured/fico-auto-score-guide/?amp_action=flush&_ts=1523607919&_url_signature=pj_Q-MhePQ2_vA9i-MTe4pBva5dy7FiXbusIBRY4yM0I9csgFG_-oZDxQcB7nx1RgTmoQw6reNJnDzzTKr1rQeK_UnT1e0E7UtshSkK545eMv3wV-PTDiWc4d2L8DW7FbkqoHUsT_gDEMdbuppnGLf7qpK2YTlIAb7_H8iQvvXr6rOaxyY_vE2lQ7nANov8dotjRR8Ao0ZenCwffGRasAnBLCwPmFhhw1aMfmFy6NLOQyXM-Tlv2Au2fhehI0I7TTgdroGW-8JjDbROucxXLnw58pfUWsJYijxnPV37dTPXxH6XgJwTi3Zro9hcT73q0oKOvQ7xRl_GPgz5BFwWQug
I have published a composer package for clearing AMP cache
@Dimasmagadan your key gets downloaded, if I click on the link. it should just return the key, like this: http://www.popsugar.com/.well-known/amphtml/apikey.pub
Hello @obeyer thanks for answering.
Actually, I've already changed my code to be run as php script and it started to work.
Earlier I've used a bash script to do exactly the same (the signatures were exact for both versions) and it somehow was unhappy with my signature.
Have you successfully updated the cache before?
Did you ever changed your public keys before you got the errors?
@codewiz same issue. Could you please help flushing my API key?
https://www-lalamira-com.cdn.ampproject.org/r/s/www.lalamira.com/.well-known/amphtml/apikey.pub
@codewiz
help me thank you !
solved thank you
@codewiz I'm experiencing the same issue as well. Would you please flush my key? https://genius-com.cdn.ampproject.org/r/s/genius.com/.well-known/amphtml/apikey.pub
Thanks
Hello @codewiz
Could you flush my next keys:
@codewiz Would really appreciate it if you helped me out by flushing the key here: https://genius-com.cdn.ampproject.org/r/s/genius.com/.well-known/amphtml/apikey.pub.
Reported recent updates internally to the AMP Cache product. Internal Id 117440746
@Gregable do you know when we can expect to see our key's cache refreshed? We've been experiencing problems for many weeks now.
To have your key refreshed: https://developers.google.com/amp/cache/update-cache#update-rsa-keys
@fueledbymarvin, particularly for your key, it was already refreshed on 2018/10/11.
@csLittleye Thank you! It appears to be working now.
Is the key caching still an issue?
Our public key is on https://cartop-carport.de/.well-known/amphtml/apikey.pub
I tried refreshing it multiple times using the explanation provided on
https://developers.google.com/amp/cache/update-cache#update-rsa-keys
but
https://cartop--carport-de.cdn.ampproject.org/r/s/cartop-carport.de/.well-known/amphtml/apikey.pub
always gives me 404. I can't spot the error.
For
https://cartop--carport-de.cdn.ampproject.org/update-cache/c/s/cartop-carport.de/amp/?amp_action=flush&_ts=1571060204&_url_signature=EjSUVz9fe4JH7W67p8G7Hy8hXd79skon6g-d4Y08u0X7vzqV5lop_6T-gICc1kpnzsE4VvNSRp5F3Aow5AJRSrjkwveP9wwMV0iKDTjvP24cfF4F4T5RfqWL_3AWz1pdCq4608JWWzhIjCxyF2JBzMTeCjx_NQ6G2DzMe0R8ZhkFRrnZzE4h7QdDLpkL8zs63g6rcb6jHIH0foye9DGHC2QNsOpwEp5ZTzFsVUnGRoyLAxTi2KGwMeauDi_4yALiykdbzdBoo0zQsW8yz8L0gdUx-LTFG-OlJMwc4k1yv7FWx937IQvO_E8aCxGfswiN0bFBawU9xOLG_AcxP6JXNg==
we get
_Invalid public key due to ingestion error: Invalid Content_
@codewiz if caching is still an issue, could you flush our public key?
Hey @codewiz can you please flush our apikey.pub too?
https://m-penoblo-de.cdn.ampproject.org/r/s/m.penoblo.de/.well-known/amphtml/apikey.pub
very thank you!
Is there any chance we can solve our issue (one post before) ?
I really don't know who else can help us with this problem.
Thank you!
Hello there,
The generated URL returns just a "OK" response, but the AMP cache is not updated, is there something I might miss?
Thanks,
Hey @codewiz, I don't know if this is still going, but i can't access my pub key from amp cdn.
Can you please flush this too?
https://amp-pisamonas-es.cdn.ampproject.org/r/s/amp.pisamonas.es/.well-known/amphtml/apikey.pub
Thank you!