TSD error: self signed certificate in certificate chain

7.9k views Asked by At

I am following the Angular 2 quick start guide and I'm stuck right at the beginning of it.

My company is filtering our network connections and modifying SSL negociation. In a man in the middle style they assign a self signed certificate as the CA of the destination's certificate.

Therefore when I execute the second command

npm install -g tsd
tsd query angular2 --action install

I get this:

stream.js:75
      throw er; // Unhandled stream error in pipe.
            ^
Error: self signed certificate in certificate chain
    at Error (native)
    at TLSSocket.<anonymous> (_tls_wrap.js:908:38)
    at emitNone (events.js:67:13)
    at TLSSocket.emit (events.js:163:7)
    at TLSSocket._finishInit (_tls_wrap.js:496:8)

Does anybody know a way of disabling the self signed certificate verification?

2

There are 2 answers

4
noelm On BEST ANSWER

One little FYI first : if you just want to learn AngularJS, maybe it's not the best way to start with TypeScript. If it's the case for you, try the tutorial on angularjs.org, which use JavaScript and angular-seed.

Anyway, if you want to use tsd, you have to edit your tsdrc file (in your user's home directory), to set the proxy, and maybe, to turn of strictSSL. See https://github.com/DefinitelyTyped/tsd#tsdrc

Following this documentation, this is what you certainly need to add to your tsdrc file :

{
    "proxy": "http://proxy.example.com:88",
    "strictSSL" : false
}

Edit : I also don't think it's an npm problem. So please update your question.

1
rjdkolb On

For yarn a very similar error occurs:

error An unexpected error occurred:
"https://registry.yarnpkg.com/generator-jhipster: self signed
certificate in certificate chain".

after

export NODE_TLS_REJECT_UNAUTHORIZED=0

I get:

error An unexpected error occurred: "https://registry.yarnpkg.com/generator-jhipster: SSL Error: SELF_SIGNED_CERT_IN_CHAIN".

Finally the solution, with the below yarn is now happy to accept the man in the middle attack by my corporate proxy.

export NODE_TLS_REJECT_UNAUTHORIZED=0
yarn config set strict-ssl false --global