chore: apply asn1 patch to GOROOT (#4694)
* Modify asn1 patch This mirrors how it is working locally: - `sudo` needs to be called this way to modify a readonly file the current user only has read access to - `sudo` may not be used to call `make patch-asn1` as it would change the user context and patch the the file for the root user (it was go 1.17 for the root user) - the network stack uses the crypt package in `GOROOT` instead of any downlaoded package via modules or vendor * Makefile fixes - make sure sudo runs with the current users paths and not with the root paths * Remove crypto tests and crypto mod These tests require crypto to be added as a mod, but the network stack won’t use the crypto package in mods or vendors but the system crypto package. Hence the tests will not validate if the network stack use the patched version
This commit is contained in:
parent
21169b84b6
commit
967de7635d
4 changed files with 9 additions and 34 deletions
16
Makefile
16
Makefile
|
|
@ -24,6 +24,10 @@ IMAGE_OPTIONS := -hostname evcc -http_port 8080 github.com/gokrazy/serial-busybo
|
|||
# deb
|
||||
PACKAGES = ./release
|
||||
|
||||
# asn1-patch
|
||||
GOROOT := $(shell go env GOROOT)
|
||||
CURRDIR := $(shell pwd)
|
||||
|
||||
default:: build
|
||||
|
||||
all:: clean install install-ui ui assets lint test-ui lint-ui test build
|
||||
|
|
@ -127,11 +131,7 @@ soc::
|
|||
|
||||
# patch asn1.go to allow Elli buggy certificates to be accepted with EEBUS
|
||||
patch-asn1::
|
||||
# echo $$(go env GOROOT)
|
||||
# cat $$(go env GOROOT)/src/vendor/golang.org/x/crypto/cryptobyte/asn1.go | grep -C 1 "out = true"
|
||||
# patch -N -t -d $$(go env GOROOT)/src/vendor/golang.org/x/crypto/cryptobyte -i $$(pwd)/patch/asn1.diff
|
||||
# cat $$(go env GOROOT)/src/vendor/golang.org/x/crypto/cryptobyte/asn1.go | grep -C 1 "out = true"
|
||||
go mod vendor
|
||||
cat vendor/golang.org/x/crypto/cryptobyte/asn1.go | grep -C 1 "out = true"
|
||||
patch -N -t -d vendor/golang.org/x/crypto/cryptobyte -i $$(pwd)/patch/asn1.diff
|
||||
cat vendor/golang.org/x/crypto/cryptobyte/asn1.go | grep -C 1 "out = true"
|
||||
# echo $(GOROOT)
|
||||
cat $(GOROOT)/src/vendor/golang.org/x/crypto/cryptobyte/asn1.go | grep -C 1 "out = true"
|
||||
sudo patch -N -t -d $(GOROOT)/src/vendor/golang.org/x/crypto/cryptobyte -i $(CURRDIR)/patch/asn1.diff
|
||||
cat $(GOROOT)/src/vendor/golang.org/x/crypto/cryptobyte/asn1.go | grep -C 1 "out = true"
|
||||
|
|
|
|||
2
go.mod
2
go.mod
|
|
@ -80,7 +80,6 @@ require (
|
|||
github.com/volkszaehler/mbmd v0.0.0-20220916215221-af29846c997e
|
||||
github.com/writeas/go-strip-markdown v2.0.1+incompatible
|
||||
gitlab.com/bboehmke/sunny v0.15.1-0.20211022160056-2fba1c86ade6
|
||||
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90
|
||||
golang.org/x/exp v0.0.0-20220827204233-334a2380cb91
|
||||
golang.org/x/net v0.0.0-20220826154423-83b083e8dc8b
|
||||
golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094
|
||||
|
|
@ -158,6 +157,7 @@ require (
|
|||
github.com/vmihailenco/msgpack/v5 v5.3.5 // indirect
|
||||
github.com/vmihailenco/tagparser/v2 v2.0.0 // indirect
|
||||
go.opencensus.io v0.23.0 // indirect
|
||||
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect
|
||||
golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4 // indirect
|
||||
golang.org/x/sync v0.0.0-20220819030929-7fc1605a5dde // indirect
|
||||
golang.org/x/sys v0.0.0-20220829200755-d48e67d00261 // indirect
|
||||
|
|
|
|||
9
main.go
9
main.go
|
|
@ -2,7 +2,6 @@ package main
|
|||
|
||||
import (
|
||||
"embed"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/fs"
|
||||
"log"
|
||||
|
|
@ -10,7 +9,6 @@ import (
|
|||
"github.com/evcc-io/evcc/cmd"
|
||||
"github.com/evcc-io/evcc/server"
|
||||
_ "github.com/evcc-io/evcc/util/goversion" // require minimum go version
|
||||
"golang.org/x/crypto/cryptobyte"
|
||||
)
|
||||
|
||||
//go:embed dist
|
||||
|
|
@ -32,12 +30,5 @@ func main() {
|
|||
// see https://github.com/golang/oauth2/issues/487
|
||||
log.SetOutput(io.Discard)
|
||||
|
||||
// Test if go is patched for accepting the buggy Elli certificate
|
||||
var res bool
|
||||
b := cryptobyte.String([]byte{0x01, 0x01, 0x01})
|
||||
if ok := b.ReadASN1Boolean(&res); !ok || !res {
|
||||
panic(fmt.Sprintf("Crypto patch missing. Run `make patch-asn1` before compiling. Debug: %v/%v (want: true/true).", ok, res))
|
||||
}
|
||||
|
||||
cmd.Execute()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,16 +0,0 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"github.com/stretchr/testify/assert"
|
||||
"golang.org/x/crypto/cryptobyte"
|
||||
)
|
||||
|
||||
func TestPatch(t *testing.T) {
|
||||
var res bool
|
||||
b := cryptobyte.String([]byte{0x01, 0x01, 0x01})
|
||||
ok := b.ReadASN1Boolean(&res)
|
||||
assert.True(t, ok, "read failed")
|
||||
assert.Equal(t, true, res, "patch failed")
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue