semantic-release / gitlab

:fox_face: semantic-release plugin to publish a GitLab release
MIT License
269 stars 77 forks source link

[Question] semantic release GitLab error when self signed certificates are used. #725

Open ievgennaida opened 1 month ago

ievgennaida commented 1 month ago

I am not able to use self-signed certificates using this plugin.

Version: "@semantic-release/gitlab": "13.1.0",

Error: UNABLE_TO_GET_ISSUER_CERT

I have tried to set next variables:


  variables:
    GIT_SSL_NO_VERIFY: 1
    NODE_OPTION: --use-openssl-ca
    NODE_EXTRA_CA_CERTS: /etc/ssl/certs/ca-certificates.crt
    NODE_TLS_REJECT_UNAUTHORIZED: 0
    NO_PROXY: {my.gitlab.com}

Certs are installed in the container

COPY *.crt /usr/local/share/ca-certificates/
RUN update-ca-certificates

Error:


[3:45:01 PM] [semantic-release] › ℹ  Start step "verifyConditions" of plugin "@semantic-release/gitlab"
[3:45:01 PM] [semantic-release] [@semantic-release/gitlab] › ℹ  Verify GitLab authentication (/api/v4)
[3:45:01 PM] [semantic-release] › ✘  Failed step "verifyConditions" of plugin "@semantic-release/gitlab"
[3:45:01 PM] [semantic-release] › ✘  An error occurred while running semantic-release: RequestError: unable to get issuer certificate
    at ClientRequest.<anonymous> (node_modules/got/dist/source/core/index.js:670:107)
    at Object.onceWrapper (node:events:633:26)
    at ClientRequest.emit (node:events:530:35)
    at TLSSocket.socketErrorListener (node:_http_client:500:9)
    at TLSSocket.emit (node:events:518:28)
    at emitErrorNT (node:internal/streams/destroy:169:8)
    at emitErrorCloseNT (node:internal/streams/destroy:128:3)
    at process.processTicksAndRejections (node:internal/process/task_queues:82:21)
    at TLSSocket.onConnectSecure (node:_tls_wrap:1674:34)
    ... 2 lines matching cause stack trace ...
    at ssl.onhandshakedone (node:_tls_wrap:871:12) {
  input: undefined,
  code: '**UNABLE_TO_GET_ISSUER_CERT**',

I would appreciate any suggestion how to use self-signed certificates.

JonasSchubert commented 1 month ago

Have a look here https://github.com/semantic-release/gitlab/issues/568. Might be the same reason

ievgennaida commented 1 month ago

@JonasSchubert Thanks for the reference. Related issue is closed I have the up to date version. But what is the current working setup?

JonasSchubert commented 1 month ago

@JonasSchubert Thanks for the reference. Related issue is closed I have the up to date version. But what is the current working setup?

https://github.com/semantic-release/gitlab/issues/489#issuecomment-1970473115 this flag might help you

JonasSchubert commented 1 month ago

@JonasSchubert Thanks for the reference. Related issue is closed I have the up to date version. But what is the current working setup?

https://github.com/semantic-release/gitlab/issues/489#issuecomment-1970473115 this flag might help you

You might have to change NODE_OPTION to NODE_OPTIONS in your variables

ievgennaida commented 1 month ago

@JonasSchubert Thanks for the reference. Related issue is closed I have the up to date version. But what is the current working setup?

#489 (comment) this flag might help you

You might have to change NODE_OPTION to NODE_OPTIONS in your variables

@JonasSchubert Thanks for the reference. Related issue is closed I have the up to date version. But what is the current working setup?

#489 (comment) this flag might help you

You might have to change NODE_OPTION to NODE_OPTIONS in your variables

Thank you for spotting, but just tested only NODE_OPTIONS in 13.0.1 and 10.1.4 and both are giving UNABLE_TO_GET_ISSUER_CERT unless NODE_TLS_REJECT_UNAUTHORIZED: 0 is used for version 10.1.4

JonasSchubert commented 4 weeks ago

Did you try this approach: https://github.com/semantic-release/gitlab/issues/489#issuecomment-1481225666

Another way without completely disabling security.

OS: Debian 11 (node:19 docker image)

If you have own CA and certificates signed with it.

Add CA to system trusted certs inside /usr/local/share/ca-certificates/, for example /usr/local/share/ca-certificates/MyCA.crt

If you have selfsigned certificates.

Add selfsigned cert:

echo | openssl s_client -servername mydomain.local -connect mydomain.local:443 2>/dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' > /usr/local/share/ca-certificates/mydomain.local.crt

And then

* run `update-ca-certificates`

* This is enough for usual tools like `curl`. Don't know why, but not enough for `got`.

* We can add `NODE_EXTRA_CA_CERTS=/etc/ssl/certs/ca-certificates.crt` variable to env, and now all is working

This is really strange, why got not use system list of trusted certs. If any body know, please tell me =)

ievgennaida commented 3 weeks ago

@JonasSchubert

Yes, this is exactly what I am doing:

Docker image:

COPY *.crt /usr/local/share/ca-certificates/
RUN update-ca-certificates

Than env is added to the gitlab variables like: variables: NODE_EXTRA_CA_CERTS: /etc/ssl/certs/ca-certificates.crt NO_PROXY: {my.gitlab.com}

Versions checked:

"@semantic-release/gitlab": "13.1.0",
"@semantic-release/gitlab": "10.1.4",

Certs are valid because other tools are ok to use them.

So far only NODE_TLS_REJECT_UNAUTHORIZED: 0 and version 10.1.4 works.

fgreinacher commented 2 weeks ago

You need to force Node to use the system certificate store, see https://github.com/semantic-release/gitlab/issues/489#issuecomment-1970473115

ievgennaida commented 2 weeks ago

@fgreinacher Node options are set.

fgreinacher commented 2 weeks ago

@ievgennaida Can you share a minimal project that reproduces this issue? That would help a lot.

JonasSchubert commented 6 hours ago

Hi @ievgennaida, I see you reached out to sindresorhus/got. Did you manage to find a solution?

ievgennaida commented 5 hours ago

Hello @JonasSchubert, unfortunately no, only old version works and issue was postponed. But I plan to test additionally direct verbose "http" and "got" module calls in the future to find a problem.