0

trying to install a nexmo voice api I'm getting an error that I can't solve alone (having limited knowledge about servers, etc.)

php /srv/www/...html/func/services/neo/voice_api_first_tts_call.php

Hi, using your key: xxxxxxxxxxxx and secret: xxxxxxxxxxx make a Call with Voice API.

0Using application ID App SMS n VoiceMail to call 0049xxxxx

Generate a JWT for  App SMS n VoiceMail.


    Fatal error: Uncaught exception 'InvalidArgumentException' with message 'It was not possible to parse your key, reason: ' in /root/vendor/lcobucci/jwt/src/Signer/Rsa.php:57

Stack trace:
 /root/vendor/lcobucci/jwt/src/Signer/Rsa.php(26): Lcobucci\JWT\Signer\Rsa->validateKey(false)

1 /root/vendor/lcobucci/jwt/src/Signer/BaseSigner.php(34): Lcobucci\JWT\Signer\Rsa->createHash('eyJ0eXA...', Object(Lcobucci\JWT\Signer\Key))

2 /root/vendor/lcobucci/jwt/src/Builder.php(241): Lcobucci\JWT\Signer\BaseSigner->sign('eyJ0eXA...', Object(Lcobucci\JWT\Signer\Key))

3 /srv/www/nhv/html/func/services/nexmo/voice_api_first_tts_call.php(61): Lcobucci\JWT\Builder->sign(Object(Lcobucci\JWT\Signer\Rsa\Sha256), Object(Lcobucci\JWT\Signer\Key))

4 /srv/www/nhv/html/func/services/nexmo/voice_api_first_tts_call.php(124): generate_token('App SMS n Voice...', 'App SMS n Voice...')

5 {main}
  thrown in /root/vendor/lcobucci/jwt/src/Signer/Rsa.php on line 57

(I am not quite sure if it's relevant, but the server has an nginx/apache setup)

I found the script where the error occurs, so i has to do with openssl...?

    private function validateKey($key)
    {
        if ($key === false) {
            throw new InvalidArgumentException(
                'It was not possible to parse your key, reason: ' . openssl_error_string()
            );
        }
        $details = openssl_pkey_get_details($key);
        if (!isset($details['key']) || $details['type'] !== OPENSSL_KEYTYPE_RSA) {
            throw new InvalidArgumentException('This key is not compatible with RSA signatures');
        }
    }    

It seems $key = false, ... so the script is missing the $key,....? which its getting here:

 $key = openssl_get_privatekey($key->getContent(), $key->getPassphrase());
Katherine Villyard
  • 18,550
  • 4
  • 37
  • 59
davidman77
  • 101
  • 2

1 Answers1

0

Answer found:

In fact a file was missing due to a raw prototype script that didnt consider that the file may be in a different folder.

davidman77
  • 101
  • 2