Understanding an Error Message

Crosspost from Understanding an error message - lemm.ee

I’m trying to follow the instructions at How to implement a basic ActivityPub server - Mastodon Blog

I get the error message:
{"error":"Unable to fetch key JSON at https://<domain>/actor"}

The actor file is located at:

that contains:

    "@context": [

    "id": "https://<domain>/actor",
    "type": "Person",
    "preferredUsername": "alice",
    "inbox": "https://<domain>/inbox",

    "publicKey": {
        "id": "https://<domain>/actor#main-key",
        "owner": "https://<domain>/actor",
        "publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAnioC3W5cHbHLo+ln4QPm\n6EX1Ypvs5h+h47b5RwhF+2N84dSHXURUuA6a33+IlVqiO/3gGxIX+4MJuSDAxGZM\nWFDbuqDnHft2zWorKmIqyDzSSB/oMSqOVL8QV1KYWsCyhw9v2l5U6EIw2Z7u3Fc9\nW19dumK0ieL7CPME2dJGV5quBoa2AGg0D36XCp8hAWMXGUnlEcaqjyePJg9/quZn\no3W/+h5ujoUQG73SIUaJdsK16Q0E7o5N7JP7pqqE8p8pEXtpwXJJYE9y9ItTqvRS\na29xymyboCI6jSK+VTgjz1tj6W+EGQsPfka6t8Gq82NL00VxBEYb/eiEFuOSy4RL\ndwIDAQAB\n-----END PUBLIC KEY-----"

I haven’t been able to find out what that error means. Is it unable to find the actor file? Maybe I should change /actor to /actor/ and put the file inside that? If so, what should the filename be?
Is it some problem with the public key inside the JSON? Is it mad about the newlines?

Hard to tell. Does https://<domain>/actor endpoint actually return a JSON object? If your server is public, you can verify your actor with this tool: https://verify.funfedi.dev

Also don’t forget to add the outbox property to your actor object, it is required by ActivityPub: ActivityPub

1 Like

returns the JSON doc I posted above.

I added an outbox property. Same error message.

It must be served with a valid ActivityPub media type in the Content-Type header for the object, or else it will be rejected. Valid media types include application/ld+json; profile="https://www.w3.org/ns/activitystreams" or optionally application/activity+json. This is done as a precaution in recent versions of common ActivityPub server implementations, to prevent situations like misinterpreting the contents of an uploaded text file attachment being misinterpreted as a valid ActivityPub object (such as for impersonation of actors on the same domain).

Thanks for the tip.
I tried setting the Conent-Type and I get the same error though.

I have the same issue - i was working on a project couple of years ago which i got back to today and regular actor profile GET request that was previously returning json with remote actor data is now returning Unable to fetch key JSON <my local actor URL here> .