Raise ValueError if the password doesn't fit

Fixes #1235. OpenSSL only allows password up to 1024 bytes.
Merge pull request #1252 from public/fix-1235

Raise ValueError if the password doesn't fit