David's Ramblings

Code and other thoughts from therabidbanana (David Haslem)

I've been trying to set up writefreely to federate with my Mastodon instance but it's been fighting me. Debug logs showed a cryptic message attempting to follow myself failed to decode PEM block:

Nov 10 03:45:39 notvery writefreely[555357]: 2022/11/10 03:45:39 Fetching actor https://notvery.social/users/therabidbanana locally
Nov 10 03:45:39 notvery writefreely[555357]: 2022/11/10 03:45:39 Not found; fetching actor https://notvery.social/users/therabidbanana remotely
Nov 10 03:45:39 notvery writefreely[555357]: 2022/11/10 03:45:39 GET https://notvery.social/users/therabidbanana
Nov 10 03:45:39 notvery writefreely[555357]: ERROR: 2022/11/10 03:45:39 activitypub.go:808: Unable to get actor! failed to decode PEM block containing private key
Nov 10 03:45:39 notvery writefreely[555357]: ERROR: 2022/11/10 03:45:39 activitypub.go:413: Unable to resolve Follow: Couldn't fetch actor.

This error turns out to come from here: https://github.com/writeas/web-core/blob/fd1559928a0f11640eded30121574376c15a396e/activitypub/keys.go#L73

But why? This is a fresh install, and writefreely generated its own keys! Turns out it is calling out to openssl to do the actual generate, and Ubuntu 22 comes with OpenSSL 3 that uses a different key format. Had to go and manually insert some traditional style RSA keys to my database to make federation work here:

https://stackoverflow.com/questions/70266909/create-pkcs1-formatted-rsa-key-using-openssl-v3-0-0

Lessons learned getting started hosting my own Mastodon instance

Read more...