Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net::ERR_CERT_COMMON_NAME_INVALID with IP Address #13

Open
Nithanaroy opened this issue Jul 20, 2020 · 7 comments
Open

net::ERR_CERT_COMMON_NAME_INVALID with IP Address #13

Nithanaroy opened this issue Jul 20, 2020 · 7 comments
Labels
question Further information is requested

Comments

@Nithanaroy
Copy link

Hi Daksh,

Thanks for sharing this resource!

How can I make this work with my local IP address, 192.168.0.5 instead of localhost?

I updated server.csr.cnf to

[req]
default_bits = 2048
prompt = no
default_md = sha256
distinguished_name = dn

[dn]
C=US
ST=RandomState
L=RandomCity
O=RandomOrganization
OU=RandomOrganizationUnit
emailAddress=hello@example.com
CN = 192.168.0.5

and v3.ext to

authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
subjectAltName = @alt_names

[alt_names]
DNS.1 = 192.168.0.5

but Chrome throws GET https://192.168.0.5:5000/socket.io/?EIO=3&transport=polling&t=NDh899k net::ERR_CERT_COMMON_NAME_INVALID

Any help on what I'm missing here :)

@dakshshah96 dakshshah96 added the question Further information is requested label Jul 20, 2020
@dakshshah96
Copy link
Owner

How can I make this work with my local IP address, 192.168.0.5 instead of localhost?

In what type of application are you trying to make this work? Is it a Node.js server or a web app using Vue/React or something else?

Please share a screenshot or the code for the file where you're including the certificate as well.

@Nithanaroy
Copy link
Author

In a Python Flask server.

from flask_socketio import SocketIO

app = Flask(__name__)
socketio = SocketIO(app, cors_allowed_origins="*")

if __name__ == '__main__':
    cwd = Path(__file__).resolve().parent.as_posix()
    socketio.run(app, host="0.0.0.0", ssl_context=(f'{cwd}/certs/trusted-openssl/server.crt', f'{cwd}/certs/trusted-openssl/server.key'))

@dakshshah96
Copy link
Owner

dakshshah96 commented Jul 20, 2020

Sorry, I'm not at all familiar with Python or Flask because of which I'm unable to determine whether this is caused by the certificate or the application.

I'll keep this issue open in case anyone else wants to help!

@Nithanaroy
Copy link
Author

Nithanaroy commented Jul 20, 2020

Thanks @dakshshah96 . I created a node.js server and tried to access the site with my ip address and didn't find the green lock in address bar like yours in README. Do you see any problems with cert generation or application below?

var path = require('path')
var fs = require('fs')
var express = require('express')
var https = require('https')

var certOptions = {
    key: fs.readFileSync(path.resolve('server.key')),
    cert: fs.readFileSync(path.resolve('server.crt'))
}

var app = express()

app.get('/', (req, res) => res.send('Hello World!'))

var server = https.createServer(certOptions, app).listen(443)

cert-invalid-with-ip

@nbilyk
Copy link

nbilyk commented Apr 27, 2021

Instead of:

[alt_names]
DNS.1 = 192.168.0.5

Could you try:

[alt_names]
IP.1 = 192.168.0.5

@ebisbe
Copy link

ebisbe commented Jan 20, 2022

In what type of application are you trying to make this work? Is it a Node.js server or a web app using Vue/React or something else?

I use a Vue 2 dev server and I have the same issue

Screenshot 2022-01-20 at 11 19 26

@ebisbe
Copy link

ebisbe commented Jan 20, 2022

I've solve it with this suggestion webpack/webpack-dev-server#416 (comment)

 devServer: {
    host: 'localhost'
  }, 

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

4 participants