Dies ist eine experimentelle Umsetzung im folgenden aufgeführten Ziele. Wie es verwendet: - Start über `evcc configure` - Die Konfiguration wird in evcc.yaml geschrieben. Falls diese existiert kann ein alternativer Dateiname angegeben werden Was es kann: - Eine geführte Erstellung der Konfigurationsdatei - Direktes Testen ob die Konfiguration jedes Gerätes auch funktioniert - Konfigurationsabhängigkeiten durch direkte Konfiguration der Abhängigkeit lösen (z.B. Sponsorshipt required) - Konfiguration in für Anwender bekannte Informationen und möglichst wenig Informationseingabe zu ermöglichen, z.B. anhand von Produkten anstatt aus der Implementierungssicht - Bisherige Konfiguration funktioniert weiter
52 lines
1.2 KiB
Go
52 lines
1.2 KiB
Go
package configure
|
|
|
|
import (
|
|
"crypto/x509/pkix"
|
|
"fmt"
|
|
|
|
certhelper "github.com/evcc-io/eebus/cert"
|
|
"github.com/evcc-io/evcc/server"
|
|
)
|
|
|
|
// configureEEBus setup EEBus
|
|
func (c *CmdConfigure) configureEEBus(conf map[string]interface{}) error {
|
|
var err error
|
|
if server.EEBusInstance, err = server.NewEEBus(conf); err == nil {
|
|
go server.EEBusInstance.Run()
|
|
}
|
|
|
|
return nil
|
|
}
|
|
|
|
// eebusCertificate setup EEBUS certificate
|
|
// returns privagte key, public key and error
|
|
func (c *CmdConfigure) eebusCertificate() (map[string]interface{}, error) {
|
|
details := server.EEBUSDetails
|
|
|
|
subject := pkix.Name{
|
|
CommonName: details.DeviceCode,
|
|
Country: []string{"DE"},
|
|
Organization: []string{details.BrandName},
|
|
}
|
|
|
|
var eebusConfig map[string]interface{}
|
|
|
|
cert, err := certhelper.CreateCertificate(true, subject)
|
|
if err != nil {
|
|
return eebusConfig, fmt.Errorf("%s", c.localizedString("Error_EEBUS_Certificate_Create", nil))
|
|
}
|
|
|
|
pubKey, privKey, err := certhelper.GetX509KeyPair(cert)
|
|
if err != nil {
|
|
return eebusConfig, fmt.Errorf("%s", c.localizedString("Error_EEBUS_Certificate_Use", nil))
|
|
}
|
|
|
|
eebusConfig = map[string]interface{}{
|
|
"certificate": map[string]string{
|
|
"public": pubKey,
|
|
"private": privKey,
|
|
},
|
|
}
|
|
|
|
return eebusConfig, nil
|
|
}
|