keep get [WDS] disconnected!
OS?
Windows 10
Versions.
@angular/cli: 1.0.0-beta.32.3 [1.0.0-beta.24] node: 6.9.1 os: win32 x64 @angular/common: 2.4.8 @angular/compiler: 2.4.8 @angular/core: 2.4.8 @angular/forms: 2.4.8 @angular/http: 2.4.8 @angular/platform-browser: 2.4.8 @angular/platform-browser-dynamic: 2.4.8 @angular/router: 3.4.8 @angular/cli: 1.0.0-beta.32.3 @angular/compiler-cli: 2.4.8
Repro steps.
use ng new PROJECT create a new project without any modification, keep get [WDS] disconnected! error after ng serve.

The error only appears under Chrome, both version 55 and 56, it works fine in Mircrosoft Edge and other browsers. I've searched the internet, most solution is about webpack, but I don't know how to config this with angular-cli. I wonder whether this is a bug related to Chrome or not, anyway, even a newly created project suffers.
Thank you for help!
@cwalv
Those attributes passed as first options to selfsigned.generate() function containing subjectAltName is not the one Chrome is complaining. It is SAN extension field and should be included in the second options object. You can see the options from selfsigned manual.
extensions: [{ name: 'basicConstraints', cA: true }], // certificate extensions array
@veke, So did you manage to create one with node.js? Just wonder if it's easier because all the instructions for OpenSSL look a bit complicated.
I made my a cert with the PowerShell command New-SelfSignedCertificate, but it's only available in Windows 10 (and maybe 8).
@violinbg @cwalv I got green certificate in chrome with this:
const fs = require("fs");
const selfsigned = require("selfsigned");
const attrs = [{ name: "commonName", value: "localhost" }];
const pems = selfsigned.generate(attrs, {
algorithm: "sha256",
keySize: 2048,
extensions: [{
name: "subjectAltName",
altNames: [{
type: 2, // DNS
value: "localhost"
}]
}]
});
fs.writeFileSync("./ssl/server.crt", pems.cert, { encoding: "utf-8" });
fs.writeFileSync("./ssl/server.key", pems.private, { encoding: "utf-8" });
It is valid for 365 days (default value).
Made a sslgen.js file to project root folder. Then I also added cert to keychains as trusted.

@veke Thanks! That script will come handy :)
Edited extension parameters. Removed URI and IP. Still got green certificate.
i am using nginx but the cert generated by selfsigned(node) not working with my domain https://mydomain.m? some idea?,
Did you added it in your OS too?
@veke yes :(, Neither with localhost

if you have latest browsers and cli installed, I have no idea. This is strange that some work for other and other not. Try to add those IP and URI fields back to script.
{
type: 6, // URI
value: 'localhost' // example
},
{
type: 7, // IP
ip: '127.0.0.1'
}
I got green certificate with that node script in two machines running OSX (haven't tested on windows yet)
What is the error in your certificate? In Chrome you need to open your dev-tools and look for security tab.
@veke this is the error: "There are issues with the site's certificate chain (net::ERR_CERT_AUTHORITY_INVALID)."
@veke the code for generate cert:
const fs = require("fs");
const selfsigned = require("selfsigned");
const attrs = [{ name: "commonName", value: "mydomain.m" }];
const pems = selfsigned.generate(attrs, {
algorithm: "sha256",
keySize: 2048,
extensions: [{
name: "subjectAltName",
altNames: [{
type: 2, // DNS
value: "localhost"
},
{
type: 6, // URI
value: 'https://mydomain.m'
},
{
type: 7, // IP
ip: '127.0.0.1'
}
]
}]
});
fs.writeFileSync("./server.crt", pems.cert, { encoding: "utf-8" });
fs.writeFileSync("./server.key", pems.private, { encoding: "utf-8" });
I deal this stuff only with local development / angular related stuff. Im not even sure you can use these in real domains :D I've seen commonName values *domain.com sometimes, maybe they need to match to those subjectAltname fields somehow... I have no idea, sorry.
@fernandops26 Certificates are read by the browser. The browser goes to a certification authority to validate the certificate. The certification authority says if the certificate is correct. With a self signed certificate there is no certification authority - so the browser can't trust it.
For a local dev environment, you can see its your certificate and so can choose to trust it - but its still not a correct certificate as it's self signed and doesn't have a certification authority associated with it. So the browser raises this ERR_CERT_AUTHORITY_INVALID.
The trick (which I still don't know how) is to get the browser to trust the certificate for your dev environment. You shouldn't ever trust a self signed certificate from real server and system admins shouldn't have a self signed certificate on a server to make it work.
This is my "basic" understanding of certificates at the moment
I used @veke code and it worked:

- generate your own cert using this code.
- install that cert in User Store > Trusted Root Certification (windows 10)
- Tell webpack to use that cert by "--https --cert ./ssl/server.crt --key ./ssl/server.key
- Profit
- Take printscreens and write a readme.txt in ./ssl for next year.
[SOLVED] With this reference you can also solve the problem, thanks: https://alexanderzeitler.com/articles/Fixing-Chrome-missing_subjectAltName-selfsigned-cert-openssl/
[SOLVED] run the angular app using npm start instead of ng serve
thanks @abergs for your solution. That worked for me.
I created file vue.config.js in root project with content below:
module.exports = {
devServer: {
disableHostCheck: true
}
}
To me solved!
@farnetani Are you using Vue? I think you're in a wrong repo. If you could explain and demonstrate that your solution will work in Angular CLI then it would be very much helpful.