phpazurelibsodiumsodium

Sodium availability in php 7.2 Azure linux/fastcgi


After some reading and samples I've been trying to use libsodium in an Azure website.

Since I read that sodium would be part of the php core since 7.2 and php site shows

no additional configuration is needed

tried Windows with fastcgi and Linux

phpinfo() shows sodium in both of them yet i cannot use it , as exampled in https://paragonie.com/book/pecl-libsodium/read/08-advanced.md#crypto-aead-aes256gcm because all i get is

Fatal error: Uncaught Error: Call to undefined function sodium_crypto_aead_aes256gcm_is_available()

my phpinfo -> 
PHP Version 7.2.1  
System  Linux 737d7217d54e 4.4.0-119-generic #143-Ubuntu SMP Mon Apr 2 16:08:24 UTC 2018 x86_64  
Server API  Apache 2.0 Handler  
PHP API 20170718  
PHP Extension   20170718  
Zend Extension  320170718  
Zend Extension Build    API320170718,NTS  
PHP Extension Build API20170718,NTS  
....  
Sodium  Frank Denis  
....

thank you all for the help


Solution

  • I had this same problem -- Azure support sent me this fix and it seems to fix libsodium issue in PHP 7.3 (7.2 is likely the same fix) -

    You need to create a settings.ini file and the .ini file should include the following:

    extension=sodium
    

    And add the PHP_INI_SCAN_DIR app setting in the azure portal to load the .ini files.