Mongosh connection error: MongoServerSelectionError: Hostname/IP does not match certificate’s altnames - database

I’m learning MongoDB and set up an Atlas account. I’m trying to connect to my database using mongosh, allowed all IPs, set up my user and password credentials but I’m getting an error:
MongoServerSelectionError: Hostname/IP does not match certificate's altnames: Host: ac-kiiemsq-shard-00-00.cbhjwlv.mongodb.net. is not in the cert's altnames: DNS:*.mongodb.net, DNS:mongodb.net
Upon checking my logs, this is what shows:
{"t":{"$date":"2023-02-15T10:21:27.465Z"},"s":"I","c":"MONGOSH","id":1000000000,"ctx":"log","msg":"Starting log","attr":{"execPath":"/opt/homebrew/Cellar/node/19.6.0/bin/node","envInfo":{"EDITOR":null,"NODE_OPTIONS":null,"TERM":"xterm-256color"},"version":"1.7.1","distributionKind":"packaged","buildArch":"x64","buildPlatform":"linux","buildTarget":"unknown","buildTime":"2023-02-13T19:19:00.135Z","gitVersion":"1bf0d7775443ac1849cc2597465d54eca867acea","nodeVersion":"v19.6.0","opensslVersion":"1.1.1s","sharedOpenssl":true}}
{"t":{"$date":"2023-02-15T10:21:27.469Z"},"s":"I","c":"MONGOSH","id":1000000005,"ctx":"config","msg":"User updated"}
{"t":{"$date":"2023-02-15T10:21:27.470Z"},"s":"I","c":"MONGOSH","id":1000000048,"ctx":"config","msg":"Loading global configuration file","attr":{"filename":"/etc/mongosh.conf","found":false}}
{"t":{"$date":"2023-02-15T10:21:27.475Z"},"s":"E","c":"DEVTOOLS-CONNECT","id":1000000041,"ctx":"mongosh-deps","msg":"Missing optional dependency","attr":{"name":"mongodb-client-encryption","error":"Cannot find module 'mongodb-client-encryption'\nRequire stack:\n- /opt/homebrew/Cellar/mongosh/1.7.1/libexec/lib/node_modules/#mongosh/cli-repl/node_modules/#mongodb-js/devtools-connect/lib/connect.js\n- /opt/homebrew/Cellar/mongosh/1.7.1/libexec/lib/node_modules/#mongosh/cli-repl/node_modules/#mongodb-js/devtools-connect/lib/index.js\n- /opt/homebrew/Cellar/mongosh/1.7.1/libexec/lib/node_modules/#mongosh/cli-repl/node_modules/#mongosh/service-provider-server/lib/cli-service-provider.js\n- /opt/homebrew/Cellar/mongosh/1.7.1/libexec/lib/node_modules/#mongosh/cli-repl/node_modules/#mongosh/service-provider-server/lib/index.js\n- /opt/homebrew/Cellar/mongosh/1.7.1/libexec/lib/node_modules/#mongosh/cli-repl/lib/cli-repl.js\n- /opt/homebrew/Cellar/mongosh/1.7.1/libexec/lib/node_modules/#mongosh/cli-repl/lib/index.js\n- /opt/homebrew/Cellar/mongosh/1.7.1/libexec/lib/node_modules/#mongosh/cli-repl/lib/run.js\n- /opt/homebrew/Cellar/mongosh/1.7.1/libexec/lib/node_modules/#mongosh/cli-repl/bin/mongosh.js"}}
{"t":{"$date":"2023-02-15T10:21:27.517Z"},"s":"I","c":"DEVTOOLS-CONNECT","id":1000000039,"ctx":"mongosh-connect","msg":"Resolving SRV record succeeded","attr":{"from":"mongodb+srv://<credentials>#cluster0.cbhjwlv.mongodb.net/myFirstDatabase?appName=mongosh+1.7.1","to":"mongodb://<credentials>#ac-kiiemsq-shard-00-00.cbhjwlv.mongodb.net,ac-kiiemsq-shard-00-01.cbhjwlv.mongodb.net,ac-kiiemsq-shard-00-02.cbhjwlv.mongodb.net/myFirstDatabase?appName=mongosh+1.7.1&authSource=admin&replicaSet=atlas-142s5d-shard-0&tls=true","resolutionDetails":[{"query":"SRV","hostname":"_mongodb._tcp.cluster0.cbhjwlv.mongodb.net","error":null,"wasNativelyLookedUp":true},{"query":"TXT","hostname":"cluster0.cbhjwlv.mongodb.net","error":null,"wasNativelyLookedUp":true}]}}
{"t":{"$date":"2023-02-15T10:21:27.530Z"},"s":"I","c":"DEVTOOLS-CONNECT","id":1000000042,"ctx":"mongosh-connect","msg":"Initiating connection attempt","attr":{"uri":"mongodb://<credentials>#ac-kiiemsq-shard-00-00.cbhjwlv.mongodb.net,ac-kiiemsq-shard-00-01.cbhjwlv.mongodb.net,ac-kiiemsq-shard-00-02.cbhjwlv.mongodb.net/myFirstDatabase?appName=mongosh+1.7.1&authSource=admin&replicaSet=atlas-142s5d-shard-0&tls=true","driver":{"name":"nodejs|mongosh","version":"4.14.0"},"devtoolsConnectVersion":"1.4.4","host":"ac-kiiemsq-shard-00-00.cbhjwlv.mongodb.net:27017,ac-kiiemsq-shard-00-01.cbhjwlv.mongodb.net:27017,ac-kiiemsq-shard-00-02.cbhjwlv.mongodb.net:27017"}}
{"t":{"$date":"2023-02-15T10:21:27.867Z"},"s":"W","c":"DEVTOOLS-CONNECT","id":1000000034,"ctx":"mongosh-connect","msg":"Server heartbeat failure","attr":{"connectionId":"ac-kiiemsq-shard-00-02.cbhjwlv.mongodb.net:27017","failure":"","isFailFast":false,"isKnownServer":true}}
{"t":{"$date":"2023-02-15T10:21:28.053Z"},"s":"W","c":"DEVTOOLS-CONNECT","id":1000000034,"ctx":"mongosh-connect","msg":"Server heartbeat failure","attr":{"connectionId":"ac-kiiemsq-shard-00-01.cbhjwlv.mongodb.net:27017","failure":"Hostname/IP does not match certificate's altnames: Host: ac-kiiemsq-shard-00-01.cbhjwlv.mongodb.net. is not in the cert's altnames: DNS:*.mongodb.net, DNS:mongodb.net","isFailFast":false,"isKnownServer":true}}
{"t":{"$date":"2023-02-15T10:21:28.200Z"},"s":"W","c":"DEVTOOLS-CONNECT","id":1000000034,"ctx":"mongosh-connect","msg":"Server heartbeat failure","attr":{"connectionId":"ac-kiiemsq-shard-00-00.cbhjwlv.mongodb.net:27017","failure":"Hostname/IP does not match certificate's altnames: Host: ac-kiiemsq-shard-00-00.cbhjwlv.mongodb.net. is not in the cert's altnames: DNS:*.mongodb.net, DNS:mongodb.net","isFailFast":false,"isKnownServer":true}}
I’ve tried connecting through Mongodb Compass and the connection is successful. I'm using a Mac with mongoDB and Mongosh installed through brew, all updated to the latest version.

If you downgrade your version of mongosh to 1.6.2, you will be able to connect.
brew uninstall mongodb-community
brew uninstall mongosh
wget https://raw.githubusercontent.com/Homebrew/homebrew-core/4519776bc4563548dcd8c8639ac7e073b107c381/Formula/mongosh.rb
brew install ./mongosh.rb

Related

Connecting Keycloak domain mode to a remote MariaDB

I wanted to deploy Keycloak (v 15.0.2) on the domain mode using MariaDB as an external DB.
Imagine my DB is on 10.0.0.1. I deploy my master on 10.0.0.1 as well by modifying the "KeycloakDS" datasource and the drivers in domain.xml.
I also wanted to deploy a slave on 10.0.0.2 by modifying the domain.xml and the host-slave.xml as the documentation of the Keycloak mentioned (link). I made the below changes on "KeycloakDS" in domain.xml:
<datasource jndi-name="java:jboss/datasources/KeycloakDS" pool-name="KeycloakDS">
<connection-url>jdbc:mariadb://10.0.0.1:3306/keycloak</connection-url>
<driver>mariadb</driver>
<security>
<user-name>myuser</user-name>
<password>mypassword</password>
</security>
</datasource>
Note telnet on 3306 from 10.0.0.2 to 10.0.0.1 is Ok.
After the above changes, I wanted to deploy the slave on 10.0.0.2 but keep facing the error below:
Caused by: java.sql.SQLNonTransientConnectionException:
Socket fail to connect to host:address=(host=localhost)(port=3306)(type=primary). Connection refused: connect
Also note that the sceneio works properly for the standalone-ha mode by making the same changes in standalone-ha.xml.
I followed this link: Installing and Configuring Keycloak - Domain Clustered Deployment
Does anyone have any suggestion that how can I solve this problem?
Try changing the datasource on both
<subsystem xmlns="urn:jboss:domain:datasources:6.0"> in /domain.xml file.
when I was reviewing the file i found there two occurrences of that subsystem.

React-native: unable to get local issuer certificate

request to https://registry.npmjs.org/expo-template-blank failed, reason: unable to get local issuer certificate
FetchError: request to https://registry.npmjs.org/expo-template-blank failed, reason: unable to get local issuer certificate
at ClientRequest. (C:\Users<username>\AppData\Roaming\npm\node_modules\expo-cli\node_modules\minipass-fetch\lib\index.js:97:14)
at ClientRequest.emit (events.js:210:5)
at TLSSocket.socketErrorListener (_http_client.js:406:9)
at TLSSocket.emit (events.js:215:7)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:80:21)
anyone having any idea?
tired below steps:
npm config set registry http://registry.npmjs.org/
npm config set strict-ssl false
NODE_TLS_REJECT_UNAUTHORIZED =0
I had the same issue, but I am behind a Corporate proxy.
I assume setting npm config set registry http://registry.npmjs.org/ does'nt help and npm client still hits the registry over https.
So I opened https://registry.npmjs.org/ from Mozilla Firefox click the Lock icon -> Connection secure -> More Info -> View Certificate
Under certificate, to right of registry.npmjs.org, I do see our corporate Cisco Umbrella certificate, so from under Miscellaneous -> Download PEM (chain)
npm config set cafile <path_to_ca_file>\cacert.pem
Now copy the contents of the download PEM (chain) towards the end of the cacert.pem file. In case you do not have a cacert.pem already, use the downloaded PEM (chain) file as the cacert.pem
Also create an environment variable NODE_EXTRA_CA_CERTS and point it to the same cacert.pem:
Windows: set NODE_EXTRA_CA_CERTS=<path_to_ca_file>\cacert.pem
Linux: export NODE_EXTRA_CA_CERTS=<path_to_ca_file>/cacert.pem
Now try:
export init MyFirstRNApp

Error connecting to Google Cloud SQL from App Engine custom environment using TCP

I'm trying to connect to google sql cloud instance from custom runtime environment in App Engine.
When I follow the doc to connect using unix domain socket, it works. The problem is when I try to connect using a TCP connect. It shows:
Warning: mysqli_connect(): (HY000/2002): Connection refused in
/var/www/html/index.php on line 3
Connect error: Connection refused
This is my app.yaml file:
runtime: custom
env: flex
beta_settings:
cloud_sql_instances: testing-mvalcam:europe-west1:testdb=tcp:3306
resources:
cpu: 1
memory_gb: 0.5
disk_size_gb: 10
The Dockerfile:
FROM php:7.0-apache
ENV PORT 8080
CMD sed -i "s/80/$PORT/g" /etc/apache2/sites-available/000-default.conf /etc/apache2/ports.conf && docker-php-entrypoint apache2-foreground
RUN docker-php-ext-install mysqli
RUN a2enmod rewrite
COPY ./src /var/www/html
EXPOSE $PORT
And index.php:
<?php
$link = mysqli_connect('127.0.0.1', 'root', 'root', 'test');
if (!$link){
die('Connect error: '. mysqli_connect_error());
}
echo 'successfully connected';
mysqli_close($link);
?>
What am I doing Wrong?
The ip address ‘172.17.0.1’ is related with the docker container where the webserver is running, you can get more context on that in this documentation.
The documentation page you’re using might be lacking on adjusting the use case if you’re deploying with a presence of a Dockerfile. In the following documentation you can read more information about App Engine flexible runtimes.
As demonstrated by the documentation you’re using (remember to click on the TCP CONNECTION tab on this page), on the section of the app.yaml related to Cloud SQL instances information about the TCP port in use by the database server is needed.

Zabbix Proxy Server Error Message: The Proxy does not match Zabbix Database

I installed a Zabbix Proxy but it won´t start. In the Proxy log is following printed:
The Proxy does not match Zabbix Database. Current database version (mandatory/optional): 03020000/03020000. Required mandatory version: 02040000

Connecting a secured websocket on Google Appengine frontend with managed VM with nodejs runtime

I've trouble in connecting to a wss secured socket server via google appengine frontend with managed VM support.
buy default google exposes only port 8080 in docker image google/nodejs-runtime, Even if expose port 8443 in Dockerfile like below i can connect only to http://localhost:8080 not https://localhost:8443
FROM google/nodejs
WORKDIR /app
ADD package.json /app/
RUN npm install
ADD . /app
EXPOSE 8443
CMD []
ENTRYPOINT ["/nodejs/bin/npm", "start"]
Still i can see port 8080 include in the container
"/nodejs/bin/npm start 8443/tcp, 0.0.0.0:8080->8080/tcp
If i log in to my managed vm instance and run the container image with
docker run -d -p 8443:8443 nodejs.default.wss-check:latest
and try
$curl https://localhost:8443
I get curl: (60) SSL certificate problem: unable to get local issuer certificate, It looks like its connecting but i've to use realdomain name
I've created a issue in github aswell https://github.com/GoogleCloudPlatform/appengine-nodejs-quickstart/issues/13, but not that helpful.
Same set up works like a charm in normal compute instance. but it doesn't auto scale.
Any help on this issue will be appreciated.
The reason you can't curl to https on localhost (curl: (60) SSL certificate problem: unable to get local issuer certificate) is because "localhost" is unknown to any CA. You need to run curl -k https://localhost:8443 to get it to ignore the lack of a certificate for localhost.
Looks like currently Google Managed VM supports Websocket connection only on JAVA
Even if you try websocket connection on with nodejs on GMV it defaults to polling transport. if you wanna see this in live you can use set socket transports, deploy to live and look in to console- network and see which transport its using!
socket.set('transports', [
'websocket'
, 'flashsocket'
, 'htmlfile'
, 'xhr-polling'
, 'jsonp-polling'
]);
We have to wait untill google implements websocket support in Managed VM. If anyone get this working on GMV, Please comment here :)

Resources