ER_CANNOT_RETRIEVE_RSA_KEY – error when connecting to MySQL with MariaDB npm package. How to fix?
When you connect to a MySQL Database with MariaDB npm package you might face this error.
SqlError: (conn=37044, no: 45044, SQLState: 08S01) RSA public key is not available client side. Either set option `cachingRsaPublicKey` to indicate public key path, or allow public key retrieval with option `allowPublicKeyRetrieval` at Object.module.exports.createError (/home/anand/Documents/PoopCode/containers/maria/digitalocean/commit/poopapp-customer-backend/node_modules/mariadb/lib/misc/errors.js:61:10) at CachingSha2PasswordAuth.exchange (/home/anand/Documents/PoopCode/containers/maria/digitalocean/commit/poopapp-customer-backend/node_modules/mariadb/lib/cmd/handshake/auth/caching-sha2-password-auth.js:89:26) at CachingSha2PasswordAuth.response (/home/anand/Documents/PoopCode/containers/maria/digitalocean/commit/poopapp-customer-backend/node_modules/mariadb/lib/cmd/handshake/auth/caching-sha2-password-auth.js:162:14) at PacketInputStream.receivePacketBasic (/home/anand/Documents/PoopCode/containers/maria/digitalocean/commit/poopapp-customer-backend/node_modules/mariadb/lib/io/packet-input-stream.js:104:9) at PacketInputStream.onData (/home/anand/Documents/PoopCode/containers/maria/digitalocean/commit/poopapp-customer-backend/node_modules/mariadb/lib/io/packet-input-stream.js:169:20) at Socket.emit (events.js:210:5) at addChunk (_stream_readable.js:308:12) at readableAddChunk (_stream_readable.js:289:11) at Socket.Readable.push (_stream_readable.js:223:10) at TCP.onStreamRead (internal/stream_base_commons.js:182:23) { text: 'RSA public key is not available client side. Either set option `cachingRsaPublicKey` to indicate public key path, or allow public key retrieval with option `allowPublicKeyRetrieval`', sql: null, fatal: true, errno: 45044, sqlState: '08S01', code: 'ER_CANNOT_RETRIEVE_RSA_KEY' }
Advertisements
To fix this just add “allowPublicKeyRetrieval”: true to your connection properties. In my case I added this property to my connection pool config.
"db": { "host": "localhost", "port":3306, "user": "root", "password": "poopcoder1234", "connectionLimit": 10, "allowPublicKeyRetrieval": true }