certmanager updated

This commit is contained in:
Олег Бородин
2024-08-06 19:10:36 +02:00
parent c7b9532377
commit f89cfe7d90
7 changed files with 281 additions and 206 deletions

View File

@@ -4,9 +4,9 @@ import (
"context"
"fmt"
"certmanager/internal/descriptor"
cmapi "certmanager/api/certmanagercontrol"
"certmanager/pkg/cm509"
"certmanager/internal/descriptor"
"certmanager/pkg/cm509"
)
func (lg *Logic) CreateServicePair(ctx context.Context, params *cmapi.CreateServicePairParams) (*cmapi.CreateServicePairResult, error) {
@@ -19,7 +19,7 @@ func (lg *Logic) CreateServicePair(ctx context.Context, params *cmapi.CreateServ
case params.IssuerID != 0:
issuerExists, issuerDescr, err = lg.db.GetIssuerByID(ctx, params.IssuerID)
if !issuerExists {
err := fmt.Errorf("No signer with this ID was found")
err := fmt.Errorf("No signer with id was found", params.IssuerID)
if err != nil {
return res, err
}
@@ -27,7 +27,7 @@ func (lg *Logic) CreateServicePair(ctx context.Context, params *cmapi.CreateServ
case params.IssuerName != "":
issuerExists, issuerDescr, err = lg.db.GetIssuerByName(ctx, params.IssuerName)
if !issuerExists {
err := fmt.Errorf("No signer with this common name was found")
err := fmt.Errorf("No signer with name %s was found", params.IssuerName)
if err != nil {
return res, err
}
@@ -56,8 +56,9 @@ func (lg *Logic) CreateServicePair(ctx context.Context, params *cmapi.CreateServ
IssuerKey: issuerDescr.Key,
IssuerCert: issuerDescr.Cert,
IPAddresses: params.InetAddresses,
DNSNames: params.Hostnames,
}
createSericePairRes, err := cm509.CreateServicePairV2(createServicePairParams)
createSericePairRes, err := cm509.CreateServicePair(createServicePairParams)
if err != nil {
return res, err
}
@@ -73,9 +74,9 @@ func (lg *Logic) CreateServicePair(ctx context.Context, params *cmapi.CreateServ
if err != nil {
return res, err
}
res.Name = createSericePairRes.Name
res.ServiceName = createSericePairRes.Name
res.ServiceID = serviceID
res.Cerificate = createSericePairRes.Cert
res.Certificate = createSericePairRes.Cert
res.Key = createSericePairRes.Key
res.IssuerID = issuerDescr.ID
res.IssuerCertificate = issuerDescr.Cert
@@ -157,7 +158,7 @@ func (lg *Logic) RevokeServicePair(ctx context.Context, params *cmapi.RevokeServ
case params.ServiceID != 0:
serviceExists, serviceDescr, err = lg.db.GetServiceByID(ctx, params.ServiceID)
if !serviceExists {
err := fmt.Errorf("No signer with this ID was found")
err := fmt.Errorf("No signer with id %d was found", params.ServiceID)
if err != nil {
return res, err
}
@@ -165,7 +166,7 @@ func (lg *Logic) RevokeServicePair(ctx context.Context, params *cmapi.RevokeServ
case params.ServiceName != "":
serviceExists, serviceDescr, err = lg.db.GetServiceByName(ctx, params.ServiceName)
if !serviceExists {
err := fmt.Errorf("No signer with this common name was found")
err := fmt.Errorf("No signer with name %s was found", params.ServiceName)
if err != nil {
return res, err
}
@@ -202,7 +203,7 @@ func (lg *Logic) UnrevokeServicePair(ctx context.Context, params *cmapi.Unrevoke
case params.ServiceID != 0:
serviceExists, serviceDescr, err = lg.db.GetServiceByID(ctx, params.ServiceID)
if !serviceExists {
err := fmt.Errorf("No signer with this ID was found")
err := fmt.Errorf("No signer with id %d was found", params.ServiceID)
if err != nil {
return res, err
}
@@ -210,7 +211,7 @@ func (lg *Logic) UnrevokeServicePair(ctx context.Context, params *cmapi.Unrevoke
case params.ServiceName != "":
serviceExists, serviceDescr, err = lg.db.GetServiceByName(ctx, params.ServiceName)
if !serviceExists {
err := fmt.Errorf("No signer with this common name was found")
err := fmt.Errorf("No signer with name %s was found", params.ServiceName)
if err != nil {
return res, err
}