title: How to fix SSL certificate error when running Npm on Windows?
body: <p>When I try to install a package with npm, it doesn't work. After a long wait, I eventually get an error 'tunneling socket could not be established, sutatusCode=403'.</p>
  
  <pre><code>$ npm install coffee-script
  npm http GET https://registry.npmjs.org/coffee-script
  npm http GET https://registry.npmjs.org/coffee-script
  npm http GET https://registry.npmjs.org/coffee-script
  npm ERR! Error: tunneling socket could not be established, sutatusCode=403
  npm ERR!     at ClientRequest.onConnect (c:\Program Files\nodejs\node_modules\npm\node_modules\request\tunnel.js:148:19)
  npm ERR!     at ClientRequest.g (events.js:193:14)
  npm ERR!     at ClientRequest.EventEmitter.emit (events.js:123:20)
  npm ERR!     at Socket.socketOnData (http.js:1393:11)
  npm ERR!     at TCP.onread (net.js:403:27)
  </code></pre>
  
  <p>However, when I browse to that same URL in my web browser (Google Chrome) it loads fine (see footnote). <a href="https://registry.npmjs.org/coffee-script">https://registry.npmjs.org/coffee-script</a></p>
  
  <p>What's going wrong?</p>
  
  <hr>
  
  <p>While I happen to use a https proxy, I'm confident this isn't the problem. I've configured the environment variable <code>https_proxy</code> (per the npm <a href="https://npmjs.org/doc/config.html">user guide</a>). I know the environment variable is correct, because the Python package manager <code>pip</code> follows it correctly.</p>
  
  <p>I believe the problem relates to SSL certificates, because if I download that URL with <code>wget</code>, I get an explicit error about certificates</p>
  
  <pre><code>$ wget https://registry.npmjs.org/coffee-script
  SYSTEM_WGETRC = c:/progra~1/wget/etc/wgetrc
  syswgetrc = c:/progra~1/wget/etc/wgetrc
  --2012-12-17 12:14:07--  https://registry.npmjs.org/coffee-script
  Resolving corpproxy... 10.254.215.35
  Connecting to corpproxy|10.254.215.35|:8080... connected.
  ERROR: cannot verify registry.npmjs.org's certificate, issued by `/C=US/ST=CA/L=Oakland/O=npm/OU=npm Certificate Authority/CN=npmCA/emailAddress=i@izs.me':
    Unable to locally verify the issuer's authority.
  To connect to registry.npmjs.org insecurely, use `--no-check-certificate'.
  Unable to establish SSL connection.
  </code></pre>
  
  <p>How can I fix this? Without compromising security.</p>
  
  <hr>
  
  <p>I used to get SSL certificate errors in my web browser too, until I installed the 'npmCA' certificate as a 'trusted root certification authority' in Control Panel's Internet Options (screenshot <img src="https://i.stack.imgur.com/0H57J.png" alt="enter image description here"> )</p>
  
  <hr>
  
  <p>Edit: I tried an <em>insecure</em> workaround per <a href="https://npmjs.org/doc/config.html#strict-ssl">https://npmjs.org/doc/config.html#strict-ssl</a></p>
  
  <pre><code>npm set strict-ssl false
  </code></pre>
  
  <p>Yet it still times out with the same error</p>
  
  <pre><code>$ npm install coffee-script
  npm http GET https://registry.npmjs.org/coffee-script
  npm http GET https://registry.npmjs.org/coffee-script
  npm http GET https://registry.npmjs.org/coffee-script
  npm ERR! Error: tunneling socket could not be established, sutatusCode=403
  </code></pre>