Skip to content

Dev server with SSR not accepting self-signed certificate #31983

@mjmustafaev

Description

@mjmustafaev

Which @angular/* package(s) are the source of the bug?

compiler

Is this a regression?

Yes

Description

Getting the below error, even though the self-signed certificate is trusted. Happening in SSR.

Error object: HttpErrorResponse {
  headers: _HttpHeaders {                                                                                                                                                        
    headers: Map(0) {},                                                                                                                                                          
    normalizedNames: Map(0) {},                                                                                                                                                  
    lazyInit: undefined,                                                                                                                                                         
    lazyUpdate: null                                                                                                                                                             
  },                                                                                                                                                                             
  status: 0,                                                                                                                                                                     
  statusText: 'Unknown Error',                                                                                                                                                   
  url: 'https://localhost:7257/articles',                                                                                                       
  ok: false,                                                                                                                                                                     
  type: undefined,                                                                                                                                                               
  redirected: undefined,                                                                                                                                                         
  responseType: undefined,                                                                                                                                                       
  name: 'HttpErrorResponse',                                                                                                                                                     
  message: 'Http failure response for https://localhost:7257/articles 0 undefined',                                                            
  error: TypeError: fetch failed                                                                                                                                                 
      at node:internal/deps/undici/undici:15845:13                                                                                                                               
      at process.processTicksAndRejections (node:internal/process/task_queues:103:5) {                                                                                           
    [cause]: Error: self-signed certificate; if the root CA is installed locally, try running Node.js with --use-system-ca                                                       
        at TLSSocket.onConnectSecure (node:_tls_wrap:1631:34)                                                                                                                    
        at TLSSocket.emit (node:events:508:28)                                                                                                                                   
        at TLSSocket._finishInit (node:_tls_wrap:1077:8)                                                                                                                         
        at ssl.onhandshakedone (node:_tls_wrap:863:12) {                                                                                                                         
      code: 'DEPTH_ZERO_SELF_SIGNED_CERT'                                                                                                                                        
    }                                                                                                                                                                            
  }                                                                                                                                                                              
}

Only workaround I found so far is to set process.env['NODE_TLS_REJECT_UNAUTHORIZED'] = '0'

Setting NODE_EXTRA_CA_CERTS didn't help.

Please provide a link to a minimal reproduction of the bug

Please provide the exception or error you saw


Please provide the environment you discovered this bug in (run ng version)

Angular CLI       : 21.0.0
Angular           : 21.0.0
Node.js           : 24.11.1
Package Manager   : npm 11.6.2
Operating System  : darwin arm64

┌───────────────────────────┬───────────────────┬───────────────────┐
│ Package                   │ Installed Version │ Requested Version │
├───────────────────────────┼───────────────────┼───────────────────┤
│ @angular/animations       │ 21.0.0            │ ^21.0.0           │
│ @angular/build            │ 21.0.0            │ ^21.0.0           │
│ @angular/cli              │ 21.0.0            │ ^21.0.0           │
│ @angular/common           │ 21.0.0            │ ^21.0.0           │
│ @angular/compiler         │ 21.0.0            │ ^21.0.0           │
│ @angular/compiler-cli     │ 21.0.0            │ ^21.0.0           │
│ @angular/core             │ 21.0.0            │ ^21.0.0           │
│ @angular/forms            │ 21.0.0            │ ^21.0.0           │
│ @angular/platform-browser │ 21.0.0            │ ^21.0.0           │
│ @angular/platform-server  │ 21.0.0            │ ^21.0.0           │
│ @angular/router           │ 21.0.0            │ ^21.0.0           │
│ @angular/ssr              │ 21.0.0            │ ^21.0.0           │
│ rxjs                      │ 7.8.2             │ ~7.8.0            │
│ typescript                │ 5.9.3             │ ~5.9.3            │
└───────────────────────────┴───────────────────┴───────────────────┘

Anything else?

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    needs: repro stepsWe cannot reproduce the issue with the information given

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions