GODT-1847: add option to export TLS Certificates in GUI.

This commit is contained in:
Xavier Michelon
2022-12-01 12:41:51 +01:00
parent 4375d77a98
commit 5b9c28e6f0
19 changed files with 2611 additions and 1389 deletions

View File

@ -21,6 +21,8 @@ import (
"context"
"encoding/base64"
"errors"
"os"
"path/filepath"
"runtime"
"github.com/Masterminds/semver/v3"
@ -348,6 +350,26 @@ func (s *Service) ReportBug(ctx context.Context, report *ReportBugRequest) (*emp
return &emptypb.Empty{}, nil
}
func (s *Service) ExportTLSCertificates(_ context.Context, folderPath *wrapperspb.StringValue) (*emptypb.Empty, error) {
s.log.WithField("folderPath", folderPath).Info("ExportTLSCertificates")
go func() {
defer s.panicHandler.HandlePanic()
cert, key := s.bridge.GetBridgeTLSCert()
if err := os.WriteFile(filepath.Join(folderPath.Value, "cert.pem"), cert, 0o600); err != nil {
_ = s.SendEvent(NewGenericErrorEvent(ErrorCode_TLS_CERT_EXPORT_ERROR))
}
if err := os.WriteFile(filepath.Join(folderPath.Value, "key.pem"), key, 0o600); err != nil {
_ = s.SendEvent(NewGenericErrorEvent(ErrorCode_TLS_KEY_EXPORT_ERROR))
}
}()
return &emptypb.Empty{}, nil
}
func (s *Service) ForceLauncher(ctx context.Context, launcher *wrapperspb.StringValue) (*emptypb.Empty, error) {
s.log.WithField("launcher", launcher.Value).Debug("ForceLauncher")