Home > database >  Chrome bug "Unable to parse ciphertext object!" with connect-mongo 4.6.0 for Node.js to st
Chrome bug "Unable to parse ciphertext object!" with connect-mongo 4.6.0 for Node.js to st

Time:11-06

In connecting my MongoDB to Node.js for storing session information by connect-mongo v.4.6.0, when testing my app in Chrome (v.106.0.5249.121), browser sends me "Unable to parse ciphertext object!". Instead, in Brave and Edge all works and session data are ciphered and stored correctly. This is my MongoStore and Express session configuration:

const MongoStore = require('connect-mongo');
const mongoStore = MongoStore.create({
    mongoUrl: urlDBLocale,
    crypto: { // this parameter causes "Unable to parse ciphertext object" in Chrome
        secret: process.env.mdbssecret,
    },
    touchAfter: 24 * 3600
});
mongoStore.on("error", err=>console.log('MongoDB Session Storage error:', err));
const sessionOptions = {
    cookie: {
        httpOnly: true, 
        secure: false, 
        maxAge: 3600000 
    },
    name:  'whatever', 
    saveUninitialized: false,
    secret: process.env.sessionSecret,
    store: mongoStore,
    resave: false
};
app.use(session(sessionOptions));

While the above simply doesn't work in Chrome, no errors are given by Brave and Edge and here you can see that sessions are stored correctly in MongoDB when I try with those two browsers respectively:

> db.sessions.find()
{ "_id" : "tAD7alup3KP_8qzkBUkAQtgplM3QYjO_", "expires" : ISODate("2022-11-03T17:54:03.169Z"), "lastModified" : ISODate("2022-11-03T16:54:03.169Z"), "session" : "MIICkwSCAThtV0dUNGZKcGYrVFlPeURDbDlTT3VqcjdFQWswRURYdm1TQXFTL1RQT3dZVzBmYU5PajRnblU0bDNuZDB3T08xTFhhbHlncnZsWUwrMHZvdWEyUzJOYUd3Wm5pUnYyOUR6SnFhODAwTXFLN3NFWG5PandKdkZmQTlvZUZZRURUVUJaeDRiYWN4T3psbXFWaFFFUlNEZzNjMFNIdnJmTXhYc2xidTkwNlovcXlTaEVGaWppRml5cEFMNlFHS2ViM1A5RElVZi9HNHRrNkVDcFpReVlGaWp1U2ZxbXNRZS9rd0NnclRua2QyYTRSTmxlT29vc1F4WUVvcnFzQzYxanJUVDVUV21laWhHTzdYeUx4VFU2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IZWxMTUxHNjNVTWZyMVEvME9VaDVJdW03TTJ6aVpGUWFJVE8vRUNaTXlqQ3NKSFFxSmw1ZGZkN1hmUDJLTFFSK2xmeVhPK0JnPT0EDIMy9uY8STWtjjUHuASBgPuj70V3HlFuaXEYk7HNYTGy6dIbrLhGkW5Ra3xTgekdMQeAdmB4xmmTnIu099LCkNeuSiZZvSLrxz6Oj39ZJXB5GTGlBVbpoEFc3Iaf12jPBhuX8KkXtHGV4y UsJw qg/BC0lzfAKMpa3iGjdLgo9vwobrN03MyEKRBUHSEyQLBBAS7AfNVrZPfHqmyGyO4g68BFh2cFprY0taekQzZ0Q4Tjd5MEcweHFwQ2dwMTJHb1dsSk04clRURnp5Rmhpc1o1WjlkQ0pyeVBTTVNhUCthS1g1d2hFMDlpbS9veGpHUGhzYkUxYS8xZz09" }

What should I do? Try a previous version of connect-mongo - and if yes, which one and with what configuration in Node.js - or is there a solution to this Chrome bug? Thanks!

CodePudding user response:

Problem solved itself in Chrome's version 107.0.5304.88.

  • Related