Upgrade only openssl to version 3 from 1.1.1 and you receive this error. sudo doesn’t work, pacman doesn’t work, what do you do?
Well hopefully you have not deleted previously downloaded packages from /var/cache/pacman/pkg/ .
If not, read about the Arch Linux Archive and you will need a USB drive/stick/whatever with an archiso written on it. I will not go there.
You however do have a previous version, for instance
Since you can’t sudo, use
su - to become root.
tar xf /var/cache/pacman/pkg/openssl-1.1.1.q-1-x86_64.pkg.tar.zst
pacman -S openssl