92 lines
2.8 KiB
Go
92 lines
2.8 KiB
Go
package logic
|
|
|
|
import (
|
|
"context"
|
|
"encoding/base64"
|
|
"encoding/json"
|
|
|
|
cmapi "certmanager/api/certmanagercontrol"
|
|
"certmanager/internal/descriptor"
|
|
//yaml "gopkg.in/yaml.v3"
|
|
)
|
|
|
|
func (lg *Logic) CreateIssuerPair(ctx context.Context, params *cmapi.CreateIssuerPairParams) (*cmapi.CreateIssuerPairResult, error) {
|
|
var err error
|
|
res := &cmapi.CreateIssuerPairResult{}
|
|
|
|
paramsJson, err := json.Marshal(params)
|
|
if err != nil {
|
|
return res, err
|
|
}
|
|
lg.log.Debugf("params: \n%s\n", string(paramsJson))
|
|
|
|
certBytes, keyBytes, err := CreateX509SelfSignedCert(params.IssuerName)
|
|
certString := base64.StdEncoding.EncodeToString(certBytes)
|
|
keyString := base64.StdEncoding.EncodeToString(keyBytes)
|
|
issuer := &descriptor.Issuer{
|
|
Name: params.IssuerName,
|
|
Cert: certString,
|
|
Key: keyString,
|
|
}
|
|
issuerID, err := lg.db.InsertIssuer(ctx, issuer)
|
|
if err != nil {
|
|
return res, err
|
|
}
|
|
res.IssuerID = issuerID
|
|
return res, err
|
|
}
|
|
|
|
func (lg *Logic) ImportIssuerPair(ctx context.Context, params *cmapi.ImportIssuerPairParams) (*cmapi.ImportIssuerPairResult, error) {
|
|
var err error
|
|
res := &cmapi.ImportIssuerPairResult{}
|
|
return res, err
|
|
}
|
|
|
|
func (lg *Logic) RevokeIssuerPair(ctx context.Context, params *cmapi.RevokeIssuerPairParams) (*cmapi.RevokeIssuerPairResult, error) {
|
|
var err error
|
|
res := &cmapi.RevokeIssuerPairResult{}
|
|
return res, err
|
|
}
|
|
|
|
func (lg *Logic) UnrevokeIssuerPair(ctx context.Context, params *cmapi.UnrevokeIssuerPairParams) (*cmapi.UnrevokeIssuerPairResult, error) {
|
|
var err error
|
|
res := &cmapi.UnrevokeIssuerPairResult{}
|
|
return res, err
|
|
}
|
|
|
|
func (lg *Logic) ListIssuerPairs(ctx context.Context, params *cmapi.ListIssuerPairsParams) (*cmapi.ListIssuerPairsResult, error) {
|
|
var err error
|
|
res := &cmapi.ListIssuerPairsResult{}
|
|
return res, err
|
|
}
|
|
|
|
func (lg *Logic) GetIssuerCertificate(ctx context.Context, params *cmapi.GetIssuerCertificateParams) (*cmapi.GetIssuerCertificateResult, error) {
|
|
var err error
|
|
res := &cmapi.GetIssuerCertificateResult{}
|
|
return res, err
|
|
}
|
|
|
|
func (lg *Logic) CreateServicePair(ctx context.Context, params *cmapi.CreateServicePairParams) (*cmapi.CreateServicePairResult, error) {
|
|
var err error
|
|
res := &cmapi.CreateServicePairResult{}
|
|
return res, err
|
|
}
|
|
|
|
func (lg *Logic) RevokeServicePair(ctx context.Context, params *cmapi.RevokeServicePairParams) (*cmapi.RevokeServicePairResult, error) {
|
|
var err error
|
|
res := &cmapi.RevokeServicePairResult{}
|
|
return res, err
|
|
}
|
|
|
|
func (lg *Logic) ListServicePairs(ctx context.Context, params *cmapi.ListServicePairsParams) (*cmapi.ListServicePairsResult, error) {
|
|
var err error
|
|
res := &cmapi.ListServicePairsResult{}
|
|
return res, err
|
|
}
|
|
|
|
func (lg *Logic) GetServicePair(ctx context.Context, params *cmapi.GetServicePairParams) (*cmapi.GetServicePairResult, error) {
|
|
var err error
|
|
res := &cmapi.GetServicePairResult{}
|
|
return res, err
|
|
}
|