Meta: Not a full answer and possibly not even a development problem, but won't reasonably fit in comments. I will delete if necessary.
If this or certain other cert-chain error(s) occurs on attempted connections to multiple valid hosts, it is most likely due to something on your machine (especially if Windows) or in the network you use (especially if a business, organization, or school) intercepting HTTPS traffic and doing so badly. This is often an 'endpoint security' or 'anti-virus' product or an IDS or IPS (Intrusion Detection or Prevention System) or DLP (Data Loss Prevention) system, but more and more things that need, or claim to need, to inspect traffic keep proliferating.
If you have or can get OpenSSL on your machine, do
openssl s_client -connect {host}:443 -showcerts <NUL:
# or </dev/null on Unix, or Unix emulation like WSL
to see exactly what cert(s) you are getting and compare them to the correct ones for that site. (https://www.ssllabs.com/ssltest is a reliable source for the correct chain(s) with some useful added analysis/commentary.)
Without OpenSSL you can get a pretty good approximation with nodejs like this:
const tls = require('tls'); const host = 'identitytoolkit.googleapis.com'; // change as appropriate
const s = tls.connect({host,port:443,servername:host,rejectUnauthorized:false},()=>{
var c = s.getPeerCertificate(true), p;
do{ console.log(c.subject); console.log(c.issuer); console.log('-----');
p = c; c = p.issuerCertificate; }while( c && c!=p );
s.destroy(); } );
On my system (with no interception) the correct output for that host is
{ CN: 'upload.video.google.com' }
{ C: 'US', O: 'Google Trust Services LLC', CN: 'GTS CA 1C3' }
-----
{ C: 'US', O: 'Google Trust Services LLC', CN: 'GTS CA 1C3' }
{ C: 'US', O: 'Google Trust Services LLC', CN: 'GTS Root R1' }
-----
{ C: 'US', O: 'Google Trust Services LLC', CN: 'GTS Root R1' }
{ C: 'BE',
O: 'GlobalSign nv-sa',
OU: 'Root CA',
CN: 'GlobalSign Root CA' }
-----
{ C: 'BE',
O: 'GlobalSign nv-sa',
OU: 'Root CA',
CN: 'GlobalSign Root CA' }
{ C: 'BE',
O: 'GlobalSign nv-sa',
OU: 'Root CA',
CN: 'GlobalSign Root CA' }
-----