2022-08-03 12:38:36 +00:00
|
|
|
/*
|
2023-09-17 07:37:43 +00:00
|
|
|
Copyright 2022-2023 CAcert Inc.
|
2022-08-03 12:38:36 +00:00
|
|
|
SPDX-License-Identifier: Apache-2.0
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
|
|
|
//go:generate go run github.com/shamaton/msgpackgen
|
|
|
|
|
|
|
|
// Package messages contains structure definitions for protocol messages
|
|
|
|
package messages
|
|
|
|
|
|
|
|
import (
|
2022-12-11 12:32:05 +00:00
|
|
|
"crypto"
|
2022-11-20 17:59:37 +00:00
|
|
|
"crypto/x509"
|
|
|
|
"encoding/pem"
|
2022-08-03 12:38:36 +00:00
|
|
|
"fmt"
|
2022-11-28 16:10:46 +00:00
|
|
|
"math/big"
|
2022-12-01 10:34:07 +00:00
|
|
|
"sort"
|
2022-11-20 09:07:02 +00:00
|
|
|
"strings"
|
2022-08-03 12:38:36 +00:00
|
|
|
"time"
|
2022-11-28 16:10:46 +00:00
|
|
|
|
|
|
|
// required for msgpackgen
|
|
|
|
_ "github.com/dave/jennifer"
|
|
|
|
"github.com/google/uuid"
|
2022-12-11 12:32:05 +00:00
|
|
|
|
|
|
|
"git.cacert.org/cacert-gosigner/internal/x509/signing"
|
2022-08-03 12:38:36 +00:00
|
|
|
)
|
|
|
|
|
2022-11-20 17:59:37 +00:00
|
|
|
type CommandCode int8
|
2022-08-03 12:38:36 +00:00
|
|
|
|
|
|
|
const (
|
2022-11-29 13:05:10 +00:00
|
|
|
CmdUndef CommandCode = iota
|
|
|
|
CmdHealth
|
2022-12-02 17:31:59 +00:00
|
|
|
CmdCAInfo
|
2022-11-20 17:59:37 +00:00
|
|
|
CmdFetchCRL
|
2022-12-02 17:31:59 +00:00
|
|
|
CmdSignCertificate
|
|
|
|
CmdSignOpenPGP
|
|
|
|
CmdRevokeCertificate
|
2022-08-03 12:38:36 +00:00
|
|
|
)
|
|
|
|
|
2022-11-20 17:59:37 +00:00
|
|
|
var commandNames = map[CommandCode]string{
|
2022-12-02 17:31:59 +00:00
|
|
|
CmdUndef: "UNDEFINED",
|
|
|
|
CmdHealth: "HEALTH",
|
|
|
|
CmdFetchCRL: "FETCH CRL",
|
|
|
|
CmdCAInfo: "CA INFO",
|
|
|
|
CmdSignCertificate: "SIG CERT",
|
|
|
|
CmdSignOpenPGP: "SIG OPENPGP",
|
|
|
|
CmdRevokeCertificate: "REV CERT",
|
2022-11-20 17:59:37 +00:00
|
|
|
}
|
|
|
|
|
2022-08-03 12:38:36 +00:00
|
|
|
func (c CommandCode) String() string {
|
2022-11-20 17:59:37 +00:00
|
|
|
if name, ok := commandNames[c]; ok {
|
|
|
|
return name
|
2022-08-03 12:38:36 +00:00
|
|
|
}
|
|
|
|
|
2022-11-20 17:59:37 +00:00
|
|
|
return fmt.Sprintf("unknown %d", c)
|
2022-08-03 12:38:36 +00:00
|
|
|
}
|
|
|
|
|
2022-11-20 17:59:37 +00:00
|
|
|
type ResponseCode int8
|
2022-08-03 12:38:36 +00:00
|
|
|
|
|
|
|
const (
|
2022-11-29 13:05:10 +00:00
|
|
|
RespError ResponseCode = -1
|
|
|
|
RespUndef ResponseCode = iota
|
|
|
|
RespHealth
|
2022-12-02 17:31:59 +00:00
|
|
|
RespCAInfo
|
2022-11-20 17:59:37 +00:00
|
|
|
RespFetchCRL
|
2022-12-02 17:31:59 +00:00
|
|
|
RespSignCertificate
|
|
|
|
RespSignOpenPGP
|
|
|
|
RespRevokeCertificate
|
2022-08-03 12:38:36 +00:00
|
|
|
)
|
|
|
|
|
2022-11-20 17:59:37 +00:00
|
|
|
var responseNames = map[ResponseCode]string{
|
2022-12-02 17:31:59 +00:00
|
|
|
RespError: "ERROR",
|
|
|
|
RespUndef: "UNDEFINED",
|
|
|
|
RespHealth: "HEALTH",
|
|
|
|
RespCAInfo: "CA INFO",
|
|
|
|
RespFetchCRL: "FETCH CRL",
|
|
|
|
RespSignCertificate: "SIG CERT",
|
|
|
|
RespSignOpenPGP: "SIG OPENPGP",
|
|
|
|
RespRevokeCertificate: "REV CERT",
|
2022-11-20 17:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (c ResponseCode) String() string {
|
|
|
|
if name, ok := responseNames[c]; ok {
|
|
|
|
return name
|
2022-11-20 09:07:02 +00:00
|
|
|
}
|
2022-11-20 17:59:37 +00:00
|
|
|
|
|
|
|
return fmt.Sprintf("unknown %d", c)
|
|
|
|
}
|
|
|
|
|
|
|
|
type CommandAnnounce struct {
|
|
|
|
Code CommandCode `msgpack:"code"`
|
2022-11-28 16:10:46 +00:00
|
|
|
ID string `msgpack:"id"`
|
2022-11-20 17:59:37 +00:00
|
|
|
Created time.Time `msgpack:"created"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *CommandAnnounce) String() string {
|
2022-11-28 16:10:46 +00:00
|
|
|
return fmt.Sprintf("code=%s, id=%s, created=%s", r.Code, r.ID, r.Created.Format(time.RFC3339))
|
2022-11-20 17:59:37 +00:00
|
|
|
}
|
|
|
|
|
2022-12-01 10:34:07 +00:00
|
|
|
func BuildCommandAnnounce(code CommandCode) *CommandAnnounce {
|
|
|
|
commandID := uuid.NewString()
|
|
|
|
|
|
|
|
return &CommandAnnounce{Code: code, ID: commandID, Created: time.Now().UTC()}
|
|
|
|
}
|
|
|
|
|
2022-11-20 17:59:37 +00:00
|
|
|
type ResponseAnnounce struct {
|
|
|
|
Code ResponseCode `msgpack:"code"`
|
|
|
|
Created time.Time `msgpack:"created"`
|
2022-11-28 16:10:46 +00:00
|
|
|
ID string `msgpack:"id"`
|
2022-11-20 17:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func (r *ResponseAnnounce) String() string {
|
2022-11-28 16:10:46 +00:00
|
|
|
return fmt.Sprintf("code=%s, id=%s, created=%s", r.Code, r.ID, r.Created.Format(time.RFC3339))
|
2022-11-20 09:07:02 +00:00
|
|
|
}
|
|
|
|
|
2022-12-01 10:34:07 +00:00
|
|
|
func BuildResponseAnnounce(code ResponseCode, commandID string) *ResponseAnnounce {
|
|
|
|
return &ResponseAnnounce{Code: code, ID: commandID, Created: time.Now().UTC()}
|
|
|
|
}
|
|
|
|
|
2022-12-11 12:32:05 +00:00
|
|
|
type CAProfile struct {
|
|
|
|
Name string `msgpack:"name"`
|
|
|
|
Description string `msgpack:"description"`
|
|
|
|
UseFor signing.ProfileUsage `msgpack:"use-for"`
|
|
|
|
}
|
2022-12-01 10:34:07 +00:00
|
|
|
|
2022-12-11 12:32:05 +00:00
|
|
|
func (p CAProfile) String() string {
|
|
|
|
return fmt.Sprintf("profile['%s': '%s']", p.Name, p.UseFor)
|
2022-12-01 10:34:07 +00:00
|
|
|
}
|
|
|
|
|
2022-12-11 12:32:05 +00:00
|
|
|
type CertificateStatus string
|
|
|
|
|
|
|
|
const (
|
|
|
|
CertStatusOk CertificateStatus = "ok"
|
|
|
|
CertStatusFailed CertificateStatus = "failed"
|
|
|
|
)
|
|
|
|
|
2022-12-02 17:31:59 +00:00
|
|
|
type CAInfoCommand struct {
|
|
|
|
Name string `msgpack:"name"`
|
|
|
|
}
|
|
|
|
|
2022-12-11 13:03:45 +00:00
|
|
|
func (c *CAInfoCommand) String() string {
|
|
|
|
return fmt.Sprintf("name=%s", c.Name)
|
2022-12-02 17:31:59 +00:00
|
|
|
}
|
|
|
|
|
2022-12-11 12:32:05 +00:00
|
|
|
type CAInfoResponse struct {
|
|
|
|
Name string `msgpack:"name"`
|
|
|
|
Certificate []byte `msgpack:"certificate"`
|
|
|
|
Signing bool `msgpack:"signing"`
|
|
|
|
Profiles []CAProfile `msgpack:"profiles"`
|
|
|
|
}
|
|
|
|
|
2022-12-11 13:03:45 +00:00
|
|
|
func (r CAInfoResponse) String() string {
|
|
|
|
return fmt.Sprintf("certificate name=%s, signing=%t, profiles=[%s]", r.Name, r.Signing, r.Profiles)
|
2022-12-11 12:32:05 +00:00
|
|
|
}
|
|
|
|
|
2022-11-20 17:59:37 +00:00
|
|
|
type FetchCRLCommand struct {
|
2022-11-30 17:47:18 +00:00
|
|
|
IssuerID string `msgpack:"issuer_id"`
|
|
|
|
LastKnownID []byte `msgpack:"last_known_id"`
|
2022-11-28 16:10:46 +00:00
|
|
|
}
|
|
|
|
|
2022-12-11 13:03:45 +00:00
|
|
|
func (c *FetchCRLCommand) String() string {
|
2022-11-28 16:10:46 +00:00
|
|
|
builder := &strings.Builder{}
|
|
|
|
|
2022-12-11 13:03:45 +00:00
|
|
|
_, _ = fmt.Fprintf(builder, "issuerId='%s'", c.IssuerID)
|
2022-11-28 16:10:46 +00:00
|
|
|
|
2022-12-11 13:03:45 +00:00
|
|
|
if c.LastKnownID != nil {
|
|
|
|
_, _ = fmt.Fprintf(builder, ", lastKnownId=0x%x", new(big.Int).SetBytes(c.LastKnownID))
|
2022-11-28 16:10:46 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
return builder.String()
|
2022-08-03 12:38:36 +00:00
|
|
|
}
|
|
|
|
|
2022-12-11 12:32:05 +00:00
|
|
|
type FetchCRLResponse struct {
|
|
|
|
IssuerID string `msgpack:"issuer_id"`
|
|
|
|
IsDelta bool `msgpack:"is_delta"`
|
|
|
|
UnChanged bool `msgpack:"unchanged"`
|
|
|
|
CRLData []byte `msgpack:"crl_data"`
|
|
|
|
CRLNumber []byte `msgpack:"crl_number"`
|
2022-08-03 13:45:27 +00:00
|
|
|
}
|
|
|
|
|
2022-12-11 12:32:05 +00:00
|
|
|
func (r *FetchCRLResponse) String() string {
|
|
|
|
builder := &strings.Builder{}
|
2022-11-20 09:07:02 +00:00
|
|
|
|
2022-12-11 12:32:05 +00:00
|
|
|
_, _ = fmt.Fprintf(
|
|
|
|
builder,
|
|
|
|
"issuer id=%s, delta=%t, unchanged=%t, CRL number=0x%x",
|
|
|
|
r.IssuerID,
|
|
|
|
r.IsDelta,
|
|
|
|
r.UnChanged,
|
|
|
|
new(big.Int).SetBytes(r.CRLNumber),
|
|
|
|
)
|
|
|
|
|
|
|
|
if r.UnChanged {
|
|
|
|
return builder.String()
|
2022-11-20 09:07:02 +00:00
|
|
|
}
|
|
|
|
|
2022-12-11 12:32:05 +00:00
|
|
|
if r.IsDelta {
|
|
|
|
_, _ = fmt.Fprintf(builder, ", delta CRL data of %d bytes not shown", len(r.CRLData))
|
2022-11-20 09:07:02 +00:00
|
|
|
|
2022-12-11 12:32:05 +00:00
|
|
|
return builder.String()
|
2022-12-01 10:34:07 +00:00
|
|
|
}
|
2022-11-30 17:42:40 +00:00
|
|
|
|
2022-12-11 12:32:05 +00:00
|
|
|
revocationList, err := x509.ParseRevocationList(r.CRLData)
|
|
|
|
if err != nil {
|
|
|
|
_, _ = fmt.Fprintf(builder, ", could not parse CRL: %s", err.Error())
|
2022-11-30 17:42:40 +00:00
|
|
|
|
2022-12-11 12:32:05 +00:00
|
|
|
return builder.String()
|
2022-11-30 17:42:40 +00:00
|
|
|
}
|
|
|
|
|
2022-12-11 12:32:05 +00:00
|
|
|
_, _ = fmt.Fprintf(
|
|
|
|
builder,
|
|
|
|
", CRL info: issuer=%s, number=0x%x, next update=%s, revoked certificates=%d",
|
|
|
|
revocationList.Issuer,
|
|
|
|
revocationList.Number,
|
|
|
|
revocationList.NextUpdate,
|
2023-09-17 07:37:43 +00:00
|
|
|
len(revocationList.RevokedCertificateEntries),
|
2022-12-11 12:32:05 +00:00
|
|
|
)
|
|
|
|
_, _ = builder.WriteString(", CRL data:\n")
|
|
|
|
_ = pem.Encode(builder, &pem.Block{
|
|
|
|
Type: "CERTIFICATE REVOCATION LIST",
|
|
|
|
Bytes: r.CRLData,
|
|
|
|
})
|
2022-11-30 17:42:40 +00:00
|
|
|
|
2022-12-11 12:32:05 +00:00
|
|
|
return builder.String()
|
2022-11-30 17:42:40 +00:00
|
|
|
}
|
|
|
|
|
2022-12-11 12:32:05 +00:00
|
|
|
type HealthCommand struct{}
|
2022-11-30 17:42:40 +00:00
|
|
|
|
2022-12-11 13:03:45 +00:00
|
|
|
func (c *HealthCommand) String() string {
|
2022-12-11 12:32:05 +00:00
|
|
|
return ""
|
2022-11-30 17:42:40 +00:00
|
|
|
}
|
|
|
|
|
2022-12-01 10:34:07 +00:00
|
|
|
type HealthInfo struct {
|
|
|
|
Source string
|
|
|
|
Healthy bool
|
|
|
|
MoreInfo map[string]string
|
|
|
|
}
|
|
|
|
|
|
|
|
func (i *HealthInfo) String() string {
|
|
|
|
builder := &strings.Builder{}
|
|
|
|
|
|
|
|
_, _ = fmt.Fprintf(builder, "source: %s, healthy: %v", i.Source, i.Healthy)
|
|
|
|
|
|
|
|
if len(i.MoreInfo) > 0 {
|
|
|
|
keys := make([]string, 0, len(i.MoreInfo))
|
|
|
|
parts := make([]string, len(i.MoreInfo))
|
|
|
|
|
|
|
|
for k := range i.MoreInfo {
|
|
|
|
keys = append(keys, k)
|
|
|
|
}
|
|
|
|
|
|
|
|
sort.Strings(keys)
|
|
|
|
|
|
|
|
for j, k := range keys {
|
|
|
|
parts[j] = fmt.Sprintf("'%s': '%s'", k, i.MoreInfo[k])
|
|
|
|
}
|
|
|
|
|
|
|
|
builder.WriteRune('[')
|
|
|
|
builder.WriteString(strings.Join(parts, ", "))
|
|
|
|
builder.WriteRune(']')
|
|
|
|
}
|
|
|
|
|
|
|
|
return builder.String()
|
|
|
|
}
|
|
|
|
|
2022-08-03 12:38:36 +00:00
|
|
|
type HealthResponse struct {
|
|
|
|
Version string `msgpack:"version"`
|
2022-11-20 17:59:37 +00:00
|
|
|
Healthy bool `msgpack:"healthy"`
|
|
|
|
Info []*HealthInfo
|
|
|
|
}
|
|
|
|
|
2022-12-11 13:03:45 +00:00
|
|
|
func (r *HealthResponse) String() string {
|
2022-11-20 17:59:37 +00:00
|
|
|
builder := &strings.Builder{}
|
|
|
|
|
2022-12-11 13:03:45 +00:00
|
|
|
_, _ = fmt.Fprintf(builder, "signer version=%s, healthy=%v, health data=[", r.Version, r.Healthy)
|
2022-12-01 10:34:07 +00:00
|
|
|
|
2022-12-11 13:03:45 +00:00
|
|
|
infos := make([]string, len(r.Info))
|
2022-11-20 17:59:37 +00:00
|
|
|
|
2022-12-11 13:03:45 +00:00
|
|
|
for i, info := range r.Info {
|
2022-12-01 10:34:07 +00:00
|
|
|
infos[i] = fmt.Sprintf("{%s}", info)
|
2022-11-20 17:59:37 +00:00
|
|
|
}
|
|
|
|
|
2022-12-01 10:34:07 +00:00
|
|
|
builder.WriteString(strings.Join(infos, ", "))
|
|
|
|
|
|
|
|
builder.WriteRune(']')
|
|
|
|
|
2022-11-20 17:59:37 +00:00
|
|
|
return builder.String()
|
|
|
|
}
|
|
|
|
|
2022-12-11 12:32:05 +00:00
|
|
|
type SignCertificateCommand struct {
|
|
|
|
IssuerID string `msgpack:"issuer_id"`
|
|
|
|
ProfileName string `msgpack:"profile_name"`
|
|
|
|
CSRData []byte `msgpack:"csr_data"`
|
|
|
|
CommonName string `msgpack:"cn"`
|
|
|
|
Organization string `msgpack:"o"`
|
|
|
|
OrganizationalUnit string `msgpack:"ou"`
|
2023-09-17 07:37:43 +00:00
|
|
|
Locality string `msgpack:"locality"`
|
|
|
|
Province string `msgpack:"province"`
|
|
|
|
Country string `msgpack:"country"`
|
2022-12-11 12:32:05 +00:00
|
|
|
Hostnames []string `msgpack:"hostnames"`
|
|
|
|
EmailAddresses []string `msgpack:"email_addresses"`
|
|
|
|
PreferredHash crypto.Hash `msgpack:"preferred_hash"`
|
2022-11-20 17:59:37 +00:00
|
|
|
}
|
|
|
|
|
2022-12-11 13:03:45 +00:00
|
|
|
func (c *SignCertificateCommand) String() string {
|
2022-11-20 17:59:37 +00:00
|
|
|
builder := &strings.Builder{}
|
|
|
|
|
2022-11-30 17:47:18 +00:00
|
|
|
_, _ = fmt.Fprintf(
|
2022-12-11 13:03:45 +00:00
|
|
|
builder, "issuer_id=%s, profile_name=%s, cn=%s", c.IssuerID, c.ProfileName, c.CommonName,
|
2022-11-30 17:47:18 +00:00
|
|
|
)
|
|
|
|
|
2022-12-11 13:03:45 +00:00
|
|
|
if c.Organization != "" {
|
|
|
|
_, _ = fmt.Fprintf(builder, ", o=%s", c.Organization)
|
2022-11-30 17:47:18 +00:00
|
|
|
}
|
2022-11-20 17:59:37 +00:00
|
|
|
|
2022-12-11 13:03:45 +00:00
|
|
|
if c.OrganizationalUnit != "" {
|
|
|
|
_, _ = fmt.Fprintf(builder, ", ou=%s", c.OrganizationalUnit)
|
2022-11-20 17:59:37 +00:00
|
|
|
}
|
|
|
|
|
2023-09-17 07:37:43 +00:00
|
|
|
if c.Locality != "" {
|
|
|
|
_, _ = fmt.Fprintf(builder, "l=%s", c.Locality)
|
|
|
|
}
|
|
|
|
|
|
|
|
if c.Province != "" {
|
|
|
|
_, _ = fmt.Fprintf(builder, "st=%s", c.Province)
|
|
|
|
}
|
|
|
|
|
|
|
|
if c.Country != "" {
|
|
|
|
_, _ = fmt.Fprintf(builder, "st=%s", c.Country)
|
|
|
|
}
|
|
|
|
|
2022-12-11 13:03:45 +00:00
|
|
|
if len(c.Hostnames) > 0 {
|
2022-12-11 12:32:05 +00:00
|
|
|
builder.WriteString(", hostnames=[")
|
2022-11-30 17:47:18 +00:00
|
|
|
|
2022-12-11 13:03:45 +00:00
|
|
|
builder.WriteString(strings.Join(c.Hostnames, ", "))
|
2022-12-11 12:32:05 +00:00
|
|
|
|
|
|
|
builder.WriteRune(']')
|
2022-11-30 17:47:18 +00:00
|
|
|
}
|
|
|
|
|
2022-12-11 13:03:45 +00:00
|
|
|
if len(c.EmailAddresses) > 0 {
|
2022-12-11 12:32:05 +00:00
|
|
|
builder.WriteString(", email_addresses=[")
|
|
|
|
|
2022-12-11 13:03:45 +00:00
|
|
|
builder.WriteString(strings.Join(c.EmailAddresses, ", "))
|
2022-12-11 12:32:05 +00:00
|
|
|
|
|
|
|
builder.WriteRune(']')
|
|
|
|
}
|
2022-11-30 17:47:18 +00:00
|
|
|
|
2022-11-20 17:59:37 +00:00
|
|
|
return builder.String()
|
2022-08-03 12:38:36 +00:00
|
|
|
}
|
|
|
|
|
2022-12-11 12:32:05 +00:00
|
|
|
type SignCertificateResponse struct {
|
|
|
|
CertificateData []byte `msgpack:"cert_data"`
|
2022-08-03 12:38:36 +00:00
|
|
|
}
|
2022-11-20 17:59:37 +00:00
|
|
|
|
2022-12-11 12:32:05 +00:00
|
|
|
func (r *SignCertificateResponse) String() string {
|
|
|
|
return fmt.Sprintf("cert_data of %d bytes", len(r.CertificateData))
|
2022-11-28 16:10:46 +00:00
|
|
|
}
|
2022-12-11 13:00:47 +00:00
|
|
|
|
|
|
|
type RevokeCertificateCommand struct {
|
|
|
|
IssuerID string `msgpack:"issuer_id"`
|
|
|
|
Serial []byte `msgpack:"serial_number"`
|
|
|
|
Reason string `msgpack:"reason"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *RevokeCertificateCommand) String() string {
|
|
|
|
builder := &strings.Builder{}
|
|
|
|
|
|
|
|
_, _ = fmt.Fprintf(
|
|
|
|
builder,
|
|
|
|
"issuerID=%s, serial=0x%s", c.IssuerID, new(big.Int).SetBytes(c.Serial).Text(16),
|
|
|
|
)
|
|
|
|
|
|
|
|
if c.Reason != "" {
|
|
|
|
_, _ = fmt.Fprintf(builder, ", reason=%s", c.Reason)
|
|
|
|
}
|
|
|
|
|
|
|
|
return builder.String()
|
|
|
|
}
|
|
|
|
|
|
|
|
type RevokeCertificateResponse struct {
|
|
|
|
IssuerID string `msgpack:"issuer_id"`
|
|
|
|
Serial []byte `msgpack:"serial_number"`
|
|
|
|
RevokedAt time.Time `msgpack:"revoked_at"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *RevokeCertificateResponse) String() string {
|
|
|
|
return fmt.Sprintf(
|
|
|
|
"issuerID=%s, serial=0x%s, revoked_at=%s",
|
|
|
|
r.IssuerID, new(big.Int).SetBytes(r.Serial).Text(16), r.RevokedAt.Format(time.RFC3339),
|
|
|
|
)
|
|
|
|
}
|
2022-12-11 13:01:48 +00:00
|
|
|
|
|
|
|
type SignOpenPGPCommand struct {
|
|
|
|
IssuerID string `msgpack:"issuer_id"`
|
|
|
|
ProfileName string `msgpack:"profile_name"`
|
|
|
|
PublicKey []byte `msgpack:"public_key"`
|
|
|
|
CommonName string `msgpack:"cn"`
|
|
|
|
EmailAddresses []string `msgpack:"email_addresses"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (c *SignOpenPGPCommand) String() string {
|
|
|
|
builder := &strings.Builder{}
|
|
|
|
|
|
|
|
_, _ = fmt.Fprintf(
|
|
|
|
builder, "issuer_id=%s, profile_name=%s, cn=%s", c.IssuerID, c.ProfileName, c.CommonName,
|
|
|
|
)
|
|
|
|
|
|
|
|
if len(c.EmailAddresses) > 0 {
|
|
|
|
builder.WriteString(", email_addresses=[")
|
|
|
|
|
|
|
|
builder.WriteString(strings.Join(c.EmailAddresses, ", "))
|
|
|
|
|
|
|
|
builder.WriteRune(']')
|
|
|
|
}
|
|
|
|
|
|
|
|
return builder.String()
|
|
|
|
}
|
|
|
|
|
|
|
|
type SignOpenPGPResponse struct {
|
|
|
|
SignatureData []byte `msgpack:"signature_data"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *SignOpenPGPResponse) String() string {
|
|
|
|
return fmt.Sprintf("sig_data of %d bytes", len(r.SignatureData))
|
|
|
|
}
|
2022-12-11 13:03:45 +00:00
|
|
|
|
|
|
|
type ErrorResponse struct {
|
|
|
|
Message string `msgpack:"message"`
|
|
|
|
}
|
|
|
|
|
|
|
|
func (r *ErrorResponse) String() string {
|
|
|
|
return fmt.Sprintf("message=%s", r.Message)
|
|
|
|
}
|