I am attempting to load a hardcoded (for the sake of testing) RSA public key in phpseclib (stable version 0.3.10). This code works perfectly correctly when run locally on my Mac and spits back out the key I entered:
CONST PUBLIC_KEY = '-----BEGIN PUBLIC KEY----- MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDYwTO/CJJQ8vbwTRQRWmOS0Pbz tFCks4RhmPxYANSQV5V9Qy+QSupewn2WAb7zV04r4RqtwxB7stDMbK+uPY+GYR5M moQuT0YStJ6TXJjiF8i1Y+DBGLnTXOD36y93V8DpuFWMxMYtROskE+Mx1W70+VTZ EM6k+jvIfzRJoVDqswIDAQAB -----END PUBLIC KEY-----'; $rsa = new Crypt_RSA(); $rsa->loadKey(self::PUBLIC_KEY); echo $rsa->getPublicKey();
However when I push it to an AWS instance running CentOS, the loadKey
call returns false. I’m not seeing any other error notifications to tell me what went wrong. Any ideas what the issue could be? Some dependency not installed?
Advertisement
Answer
The issue is from having mbstring function overloading enabled on the CentOS server but not locally, which is breaking some of the binary data comparisons. I’ll need to find a way around that when performing the encryption.