From 940f6f100fbf73bd42b186cee6d29a2b207f8041 Mon Sep 17 00:00:00 2001 From: Andreas Linde <42185+DerAndereAndi@users.noreply.github.com> Date: Sat, 1 Oct 2022 19:15:29 +0200 Subject: [PATCH] Check for patched go crypto lib at runtime (#4671) Panic if the used crypto library is not being used for compiling --- server/eebus.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/server/eebus.go b/server/eebus.go index c1f6e9c20..0ce8f7930 100644 --- a/server/eebus.go +++ b/server/eebus.go @@ -19,6 +19,7 @@ import ( "github.com/evcc-io/evcc/util" "github.com/evcc-io/evcc/util/machine" "github.com/libp2p/zeroconf/v2" + "golang.org/x/crypto/cryptobyte" ) var EEBUSDetails = communication.ManufacturerDetails{ @@ -92,6 +93,13 @@ func NewEEBus(other map[string]interface{}) (*EEBus, error) { return nil, err } + // 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 { + panic("EEBUS needs a patched go crypto library. Run `make patch-asn1` before compiling.") + } + srv := &server.Server{ Log: log.TRACE, Addr: cc.Uri,