certmanager updated
This commit is contained in:
@@ -24,6 +24,12 @@ func (util *Util) CreateIssuerPair(ctx context.Context) (*cmapi.CreateIssuerPair
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
certPEM, err := base64.StdEncoding.DecodeString(res.Certificate)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
res.Certificate = string(certPEM)
|
||||
|
||||
return res, err
|
||||
}
|
||||
|
||||
|
||||
@@ -36,6 +36,7 @@ const (
|
||||
getIssuerCertificateCmd = "getIssuerCertificate"
|
||||
createServicePairCmd = "createServicePair"
|
||||
revokeServicePairCmd = "revokeServicePair"
|
||||
unrevokeServicePairCmd = "unrevokeServicePair"
|
||||
listServicePairsCmd = "listServicePairs"
|
||||
getServicePairCmd = "getServicePair"
|
||||
)
|
||||
@@ -56,20 +57,19 @@ type Util struct {
|
||||
access client.Access
|
||||
cont *cmapi.ControlClient
|
||||
|
||||
caFilenamesList string
|
||||
certFilename string
|
||||
hostnameList string
|
||||
ipAdressesList string
|
||||
issuerCommonName string
|
||||
issuerID int64
|
||||
issuerName string
|
||||
keyFilename string
|
||||
|
||||
signerID int64
|
||||
signerName string
|
||||
|
||||
serviceID int64
|
||||
serviceName string
|
||||
caFilenamesList string
|
||||
certFilename string
|
||||
hostnameList string
|
||||
ipAdressesList string
|
||||
issuerCommonName string
|
||||
issuerID int64
|
||||
issuerName string
|
||||
keyFilename string
|
||||
signerID int64
|
||||
signerName string
|
||||
serviceCommonName string
|
||||
serviceID int64
|
||||
serviceName string
|
||||
}
|
||||
|
||||
func NewUtil() *Util {
|
||||
@@ -260,6 +260,13 @@ func (util *Util) GetOpt() error {
|
||||
case createServicePairCmd:
|
||||
flagSet := flag.NewFlagSet(createServicePairCmd, flag.ExitOnError)
|
||||
|
||||
flagSet.StringVar(&util.issuerCommonName, "cn", util.issuerCommonName, "new service canonic name")
|
||||
flagSet.StringVar(&util.issuerName, "issuerName", util.issuerName, "issuer name")
|
||||
flagSet.Int64Var(&util.issuerID, "issuerID", util.issuerID, "issuer ID")
|
||||
|
||||
flagSet.StringVar(&util.ipAdressesList, "addresses", util.ipAdressesList, "comma separated IP address list")
|
||||
flagSet.StringVar(&util.hostnameList, "hostnames", util.hostnameList, "comma separated hostname list")
|
||||
|
||||
flagSet.Usage = func() {
|
||||
fmt.Printf("\n")
|
||||
fmt.Printf("Usage: %s [global options] %s [command options]\n", exeName, subCmd)
|
||||
@@ -274,6 +281,26 @@ func (util *Util) GetOpt() error {
|
||||
case revokeServicePairCmd:
|
||||
flagSet := flag.NewFlagSet(revokeServicePairCmd, flag.ExitOnError)
|
||||
|
||||
flagSet.StringVar(&util.serviceName, "serviceName", util.serviceName, "service name")
|
||||
flagSet.Int64Var(&util.serviceID, "serviceID", util.serviceID, "service ID")
|
||||
|
||||
flagSet.Usage = func() {
|
||||
fmt.Printf("\n")
|
||||
fmt.Printf("Usage: %s [global options] %s [command options]\n", exeName, subCmd)
|
||||
fmt.Printf("\n")
|
||||
fmt.Printf("The command options: none\n")
|
||||
flagSet.PrintDefaults()
|
||||
fmt.Printf("\n")
|
||||
}
|
||||
flagSet.Parse(subArgs)
|
||||
util.subCmd = subCmd
|
||||
|
||||
case unrevokeServicePairCmd:
|
||||
flagSet := flag.NewFlagSet(unrevokeServicePairCmd, flag.ExitOnError)
|
||||
|
||||
flagSet.StringVar(&util.serviceName, "serviceName", util.serviceName, "service name")
|
||||
flagSet.Int64Var(&util.serviceID, "serviceID", util.serviceID, "service ID")
|
||||
|
||||
flagSet.Usage = func() {
|
||||
fmt.Printf("\n")
|
||||
fmt.Printf("Usage: %s [global options] %s [command options]\n", exeName, subCmd)
|
||||
@@ -302,6 +329,9 @@ func (util *Util) GetOpt() error {
|
||||
case getServicePairCmd:
|
||||
flagSet := flag.NewFlagSet(getServicePairCmd, flag.ExitOnError)
|
||||
|
||||
flagSet.StringVar(&util.serviceName, "serviceName", util.serviceName, "service name")
|
||||
flagSet.Int64Var(&util.serviceID, "serviceID", util.serviceID, "service ID")
|
||||
|
||||
flagSet.Usage = func() {
|
||||
fmt.Printf("\n")
|
||||
fmt.Printf("Usage: %s [global options] %s [command options]\n", exeName, subCmd)
|
||||
@@ -312,7 +342,6 @@ func (util *Util) GetOpt() error {
|
||||
}
|
||||
flagSet.Parse(subArgs)
|
||||
util.subCmd = subCmd
|
||||
|
||||
default:
|
||||
help()
|
||||
return errors.New("Unknown command")
|
||||
@@ -356,12 +385,13 @@ func (util *Util) Exec() error {
|
||||
case createServicePairCmd:
|
||||
res, err = util.CreateServicePair(ctx)
|
||||
case revokeServicePairCmd:
|
||||
res, err = util.CreateServicePair(ctx)
|
||||
res, err = util.RevokeServicePair(ctx)
|
||||
case unrevokeServicePairCmd:
|
||||
res, err = util.UnrevokeServicePair(ctx)
|
||||
case listServicePairsCmd:
|
||||
res, err = util.ListServicePairs(ctx)
|
||||
case getServicePairCmd:
|
||||
res, err = util.GetServicePair(ctx)
|
||||
|
||||
default:
|
||||
err = errors.New("Unknown cli command")
|
||||
}
|
||||
|
||||
@@ -2,6 +2,8 @@ package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"encoding/base64"
|
||||
"strings"
|
||||
|
||||
cmapi "certmanager/api/certmanagercontrol"
|
||||
"certmanager/pkg/client"
|
||||
@@ -14,11 +16,35 @@ func (util *Util) CreateServicePair(ctx context.Context) (*cmapi.CreateServicePa
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
params := &cmapi.CreateServicePairParams{}
|
||||
inetAddresses := strings.Split(util.ipAdressesList, ",")
|
||||
hostnames := strings.Split(util.hostnameList, ",")
|
||||
|
||||
params := &cmapi.CreateServicePairParams{
|
||||
IssuerName: util.issuerName,
|
||||
IssuerID: util.issuerID,
|
||||
ServiceCommonName: util.serviceCommonName,
|
||||
InetAddresses: inetAddresses,
|
||||
Hostnames: hostnames,
|
||||
}
|
||||
res, err = cli.CreateServicePair(ctx, params)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
certPEM, err := base64.StdEncoding.DecodeString(res.Certificate)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
res.Certificate = string(certPEM)
|
||||
keyPEM, err := base64.StdEncoding.DecodeString(res.Key)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
res.Key = string(keyPEM)
|
||||
caPEM, err := base64.StdEncoding.DecodeString(res.IssuerCertificate)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
res.IssuerCertificate = string(caPEM)
|
||||
return res, err
|
||||
}
|
||||
|
||||
@@ -29,7 +55,10 @@ func (util *Util) RevokeServicePair(ctx context.Context) (*cmapi.RevokeServicePa
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
params := &cmapi.RevokeServicePairParams{}
|
||||
params := &cmapi.RevokeServicePairParams{
|
||||
ServiceName: util.serviceName,
|
||||
ServiceID: util.serviceID,
|
||||
}
|
||||
res, err = cli.RevokeServicePair(ctx, params)
|
||||
if err != nil {
|
||||
return res, err
|
||||
@@ -37,6 +66,24 @@ func (util *Util) RevokeServicePair(ctx context.Context) (*cmapi.RevokeServicePa
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (util *Util) UnrevokeServicePair(ctx context.Context) (*cmapi.UnrevokeServicePairResult, error) {
|
||||
var err error
|
||||
res := &cmapi.UnrevokeServicePairResult{}
|
||||
cli, err := client.NewClient(&util.access)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
params := &cmapi.UnrevokeServicePairParams{
|
||||
ServiceName: util.serviceName,
|
||||
ServiceID: util.serviceID,
|
||||
}
|
||||
res, err = cli.UnrevokeServicePair(ctx, params)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (util *Util) ListServicePairs(ctx context.Context) (*cmapi.ListServicePairsResult, error) {
|
||||
var err error
|
||||
res := &cmapi.ListServicePairsResult{}
|
||||
@@ -59,10 +106,28 @@ func (util *Util) GetServicePair(ctx context.Context) (*cmapi.GetServicePairResu
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
params := &cmapi.GetServicePairParams{}
|
||||
params := &cmapi.GetServicePairParams{
|
||||
ServiceID: util.serviceID,
|
||||
ServiceName: util.serviceName,
|
||||
}
|
||||
res, err = cli.GetServicePair(ctx, params)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
certPEM, err := base64.StdEncoding.DecodeString(res.Certificate)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
res.Certificate = string(certPEM)
|
||||
keyPEM, err := base64.StdEncoding.DecodeString(res.Key)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
res.Key = string(keyPEM)
|
||||
caPEM, err := base64.StdEncoding.DecodeString(res.IssuerCertificate)
|
||||
if err != nil {
|
||||
return res, err
|
||||
}
|
||||
res.IssuerCertificate = string(caPEM)
|
||||
return res, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user