Skip to content

Golang cannot parse the root certificate for Alipay payment. x509: unsupported elliptic curve #70136

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
mimicode opened this issue Oct 31, 2024 · 5 comments
Labels
WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.

Comments

@mimicode
Copy link

Go version

go version go1.22.6 windows/amd64

Output of go env in your module/workspace:

set GO111MODULE=on
set GOARCH=amd64                              
set GOBIN=                                    
set GOCACHE=C:\Users\HR\AppData\Local\go-build
set GOENV=C:\Users\HR\AppData\Roaming\go\env  
set GOEXE=.exe                                
set GOEXPERIMENT=                             
set GOFLAGS=                                  
set GOHOSTARCH=amd64                          
set GOHOSTOS=windows                          
set GOINSECURE=                               
set GOMODCACHE=C:\Users\HR\go\pkg\mod         
set GONOPROXY=               
set GONOSUMDB=               
set GOOS=windows                              
set GOPATH=C:\Users\HR\go                     
set GOPRIVATE=               
set GOPROXY=https://goproxy.cn,direct
set GOROOT=C:/Users/HR/go/pkg/mod/golang.org/[email protected]
set GOSUMDB=sum.golang.org
set GOTMPDIR=
set GOTOOLCHAIN=auto
set GOTOOLDIR=C:\Users\HR\go\pkg\mod\golang.org\t[email protected]\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.22.6
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=D:\work\code\testcode\go.mod
set GOWORK=
set CGO_CFLAGS=-O2 -g
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-O2 -g
set CGO_FFLAGS=-O2 -g
set CGO_LDFLAGS=-O2 -g
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=C:\Users\HR\AppData\Local\Temp\go-build2810565051=/tmp/go-build -gno-record-gcc-switches

What did you do?

https://go.dev/play/p/IWbLhFMHQz4?v=goprev

What did you see happen?

When extracting and parsing the certificate, the error message "x509: unsupported elliptic curve" is displayed.

What did you expect to see?

I can get the correct results when using openssl_x509_parse in PHP, but it does not work in Go.

@mauri870
Copy link
Member

This is expected as Go does not support SM algorithms. The certificate you posted uses SM2 and SM3. These are Chinese Standards for encryption.

See https://cran.r-project.org/web/packages/smcryptoR/smcryptoR.pdf

@mauri870
Copy link
Member

You can convert this issue into a proposal if you wish to add these algorithms to the standard library. Otherwise there are packages that implement these standards available, for example https://github.com/tjfoc/gmsm.

@cagedmantis cagedmantis added the WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided. label Oct 31, 2024
@seankhliao
Copy link
Member

Duplicate of #54087

@seankhliao seankhliao marked this as a duplicate of #54087 Oct 31, 2024
@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Oct 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
WaitingForInfo Issue is not actionable because of missing required information, which needs to be provided.
Projects
None yet
Development

No branches or pull requests

5 participants