amplify init error "unable to get local issuer certificate" even with no proxy

2.8k Views Asked by At

I am trying to initialize the amplify but it is failling due to network error. Below is command stack.

amplify init
Note: It is recommended to run this command from the root of your app directory
? Enter a name for the project useapp
The following configuration will be applied:

Project information
| Name: useapp
| Environment: dev
| Default editor: Visual Studio Code
| App type: javascript
| Javascript framework: none
| Source Directory Path: src
| Distribution Directory Path: dist
| Build Command: npm.cmd run-script build
| Start Command: npm.cmd run-script start

? Initialize the project with the above configuration? Yes
Using default provider  awscloudformation
? Select the authentication method you want to use: AWS access keys
? accessKeyId:  ********************
? secretAccessKey:  ****************************************
? region:  ap-south-1
Error: unable to get local issuer certificate
    at TLSSocket.onConnectSecure (_tls_wrap.js:1497:34)   
    at TLSSocket.emit (events.js:315:20)
    at TLSSocket.EventEmitter.emit (domain.js:467:12)     
    at TLSSocket._finishInit (_tls_wrap.js:932:8)
    at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:706:12) {
  code: 'NetworkingError',
  region: 'ap-south-1',
  hostname: 'amplify.ap-south-1.amazonaws.com',
  retryable: true,
  time: 2021-04-20T12:27:20.274Z
}

I checked many forums. It happens when proxy is involved (General suggestion is to set environment variables http_proxy and https_proxy). Though my laptop is on company VPN but there is no proxy set. please find the output of netsh command

    PS C:\Windows\system32> netsh winhttp show proxy

    Current WinHTTP proxy settings:

        Direct access (no proxy server).

    PS C:\Windows\system32>

Please help me to solve the issue.

2

There are 2 best solutions below

2
On

I had exactly the same problem as you on a company laptop and what I did was disable the VPN. Generally companies use a VPN software, in my case it's called ZScaler, it always has the icon on the taskbar, what you should do is exit. ZScaller icon

0
On

The issue is that the AWS JS SDK for Node does not directly support the CA bundle configuration (as described here https://github.com/aws/aws-sdk-js/issues/2970).

In the comments, a solution is noted, that by setting the environment variable

NODE_EXTRA_CA_CERTS = /path/to/certificate

to point to the root certificate file (you will need to ask your company for access to that)

it will then be able to find the issuer certificate.