Make this assertion less fragile

There's no guarantee of the exception's class, so I don't see a reason for this
to be so strongly tied to the OpenSSL PKey parsing behavior.