PHP -Error: pack(): Type H: illegal hex digit - at /var/www/nextcloud/3rdparty/phpseclib/phpseclib/phpseclib/Crypt/RSA.php#1147

NC v. 21.0.4; OS v. Ubuntu 20.04; Nginx 1.21.1; PHP 8.0.9

The issue you are facing:
I cannot open (from settings) my external storage. I am seeing a repeating logging error of:

Error: pack(): Type H: illegal hex digit - at /var/www/nextcloud/3rdparty/phpseclib/phpseclib/phpseclib/Crypt/RSA.php#1147

Is this related to phpseclib?

Is this the first time you’ve seen this error? (Y): with this version of NC

Steps to replicate it:

  1. automatically keeps adding to logging errors

The output of your Nextcloud log in Admin > Logging:

Error: pack(): Type H: illegal hex digit - at /var/www/nextcloud/3rdparty/phpseclib/phpseclib/phpseclib/Crypt/RSA.php#1147

    <<closure>>

    OC\Log\ErrorHandler::onError()

    /var/www/nextcloud/3rdparty/phpseclib/phpseclib/phpseclib/Crypt/RSA.php - line 1147:

    pack()

    /var/www/nextcloud/3rdparty/phpseclib/phpseclib/phpseclib/Crypt/RSA.php - line 1710:

    phpseclib\Crypt\RSA->_parseKey()

    /var/www/nextcloud/apps/files_external/lib/Lib/Auth/PublicKey/RSAPrivateKey.php - line 61:

    phpseclib\Crypt\RSA->loadKey()

    /var/www/nextcloud/apps/files_external/lib/Config/ConfigAdapter.php - line 94:

    OCA\Files_External\Lib\Auth\PublicKey\RSAPrivateKey->manipulateStorageConfig()

    /var/www/nextcloud/apps/files_external/lib/Config/ConfigAdapter.php - line 132:

    OCA\Files_External\Config\ConfigAdapter->prepareStorageConfig()

    <<closure>>

    OCA\Files_External\Config\ConfigAdapter->OCA\Files_External\Config\{closure}("*** sensiti ... *")

    /var/www/nextcloud/apps/files_external/lib/Config/ConfigAdapter.php - line 130:

    array_map()

    /var/www/nextcloud/lib/private/Files/Config/MountProviderCollection.php - line 109:

    OCA\Files_External\Config\ConfigAdapter->getMountsForUser()

    /var/www/nextcloud/lib/private/Files/Filesystem.php - line 452:

    OC\Files\Config\MountProviderCollection->addMountForUser()

    /var/www/nextcloud/lib/private/Files/Filesystem.php - line 377:

    OC\Files\Filesystem::initMountPoints()

    /var/www/nextcloud/lib/private/legacy/OC_Util.php - line 324:

    OC\Files\Filesystem::init()

    /var/www/nextcloud/apps/dav/lib/Connector/Sabre/Auth.php - line 125:

    OC_Util::setupFS()

    /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Auth/Backend/AbstractBasic.php - line 103:

    OCA\DAV\Connector\Sabre\Auth->validateUserPass("*** sensiti ... *")

    /var/www/nextcloud/apps/dav/lib/Connector/Sabre/Auth.php - line 254:

    Sabre\DAV\Auth\Backend\AbstractBasic->check()

    /var/www/nextcloud/apps/dav/lib/Connector/Sabre/Auth.php - line 156:

    OCA\DAV\Connector\Sabre\Auth->auth()

    /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Auth/Plugin.php - line 182:

    OCA\DAV\Connector\Sabre\Auth->check()

    /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Auth/Plugin.php - line 137:

    Sabre\DAV\Auth\Plugin->check()

    /var/www/nextcloud/3rdparty/sabre/event/lib/WildcardEmitterTrait.php - line 89:

    Sabre\DAV\Auth\Plugin->beforeMethod()

    /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 456:

    Sabre\DAV\Server->emit()

    /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 253:

    Sabre\DAV\Server->invokeMethod()

    /var/www/nextcloud/3rdparty/sabre/dav/lib/DAV/Server.php - line 321:

    Sabre\DAV\Server->start()

    /var/www/nextcloud/apps/dav/lib/Server.php - line 332:

    Sabre\DAV\Server->exec()

    /var/www/nextcloud/apps/dav/appinfo/v2/remote.php - line 35:

    OCA\DAV\Server->exec()

    /var/www/nextcloud/remote.php - line 167:

    require_once("/var/www/ne ... p")

The output of your config.php file in /path/to/nextcloud (make sure you remove any identifiable information!):

<?php
$CONFIG = array (
  'instanceid' => 'XXXXXXXXXXXX',
  'passwordsalt' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
  'secret' => 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
  'trusted_domains' =>
  array (
    0 => 'stanworth.cloud',
  ),
  'datadirectory' => '/var/nc_data',
  'dbtype' => 'mysql',
  'version' => '21.0.4.1',
  'overwrite.cli.url' => 'https://stanworth.cloud',
  'dbname' => 'nextcloud',
  'dbhost' => 'localhost',
  'dbport' => '',
  'dbtableprefix' => 'oc_',
  'mysql.utf8mb4' => true,
  'dbuser' => 'XXXXXXXXXXXX',
  'dbpassword' => 'XXXXXXXXXXXX',
  'installed' => true,
  'activity_expire_days' => 14,
  'auth.bruteforce.protection.enabled' => true,
  'blacklisted_files' =>
  array (
    0 => '.htaccess',
    1 => 'Thumbs.db',
    2 => 'thumbs.db',
  ),
  'cron_log' => true,
  'default_phone_region' => 'TW',
  'enable_previews' => true,
  'enabledPreviewProviders' =>
  array (
    0 => 'OC\\Preview\\PNG',
    1 => 'OC\\Preview\\JPEG',
    2 => 'OC\\Preview\\GIF',
    3 => 'OC\\Preview\\BMP',
    4 => 'OC\\Preview\\XBitmap',
    5 => 'OC\\Preview\\Movie',
    6 => 'OC\\Preview\\PDF',
    7 => 'OC\\Preview\\MP3',
    8 => 'OC\\Preview\\TXT',
    9 => 'OC\\Preview\\MarkDown',
  ),
  'filesystem_check_changes' => 0,
  'filelocking.enabled' => 'true',
  'htaccess.RewriteBase' => '/',
  'integrity.check.disabled' => false,
  'knowledgebaseenabled' => false,
  'logfile' => '/var/nc_data/nextcloud.log',
  'loglevel' => 2,
  'logtimezone' => 'Asia/Taipei',
  'log_rotate_size' => 104857600,
  'maintenance' => false,
  'memcache.local' => '\\OC\\Memcache\\APCu',
  'memcache.locking' => '\\OC\\Memcache\\Redis',
  'overwriteprotocol' => 'https',
  'preview_max_x' => 1024,
  'preview_max_y' => 768,
  'preview_max_scale_factor' => 1,
  'redis' =>
  array (
    'host' => '/var/run/redis/redis-server.sock',
    'port' => 0,
    'timeout' => 0.0,
  ),
  'quota_include_external_storage' => false,
  'share_folder' => '/Shares',
  'skeletondirectory' => '',
  'theme' => '',
  'trashbin_retention_obligation' => 'auto, 7',
  'updater.release.channel' => 'stable',
  'data-fingerprint' => 'XXXXXXXXXXXXXXXXXXXXXXXXXX',
  'mail_smtpmode' => 'smtp',
  'mail_smtpsecure' => 'ssl',
  'mail_sendmailmode' => 'smtp',
  'mail_smtpauthtype' => 'LOGIN',
  'mail_smtpauth' => 1,
  'mail_smtpport' => '465',
  'mail_smtphost' => 'smtp.gmail.com',
  'mail_from_address' => 'XXXXXXXX',
  'mail_domain' => 'gmail.com',
  'mail_smtpname' => 'XXXXXX',
  'mail_smtppassword' => 'XXXXXXXXXXXXXXXX',
  'updater.secret' => 'XXXXXXXXXXXXXXXXXXXXX',

The output of your Apache/nginx/system log in /var/log/____: I’m not seeing a system log so this is the error.log - It has rolled many times here is the recent part

2021/08/18 10:38:45 [warn] 229080#229080: *3888 an upstream response is buffered to a temporary file /var/cache/nginx/fastcgi_temp/1/00/0000000001 while reading upstream, client: 122.117.185.116, server: stanworth.cloud, request: "GET /settings/apps/list HTTP/2.0", upstream: "fastcgi://unix:/run/php/php8.0-fpm.sock:", host: "stanworth.cloud"