Looking at the api documentation again, it is possible that they want this: pubkey = open( 'pubkey.pem', 'rb' ).read() # binary read here? rsa = M2Crypto.RSA.load_pub_key(pubkey) Anyway, things to play with...