Skip to content

Commit

Permalink
Use any instead of interface{}, update deps
Browse files Browse the repository at this point in the history
  • Loading branch information
mjwhitta committed Jul 15, 2023
1 parent 582dc09 commit 9236dad
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 50 deletions.
35 changes: 14 additions & 21 deletions cmd/certify/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package main
import (
"os"
"path/filepath"
"strings"

"github.com/mjwhitta/cli"
hl "github.com/mjwhitta/hilighter"
Expand Down Expand Up @@ -46,27 +45,21 @@ func init() {
os.Args[0],
)
cli.BugEmail = "pki.bugs@whitta.dev"
cli.ExitStatus = strings.Join(
[]string{
"Normally the exit status is 0. In the event of an error",
"the exit status will be one of the below:\n\n",
hl.Sprintf("%d: Invalid option\n", InvalidOption),
hl.Sprintf("%d: Missing option\n", MissingOption),
hl.Sprintf("%d: Invalid argument\n", InvalidArgument),
hl.Sprintf("%d: Missing argument\n", MissingArgument),
hl.Sprintf("%d: Extra argument\n", ExtraArgument),
hl.Sprintf("%d: Exception", Exception),
},
" ",
cli.ExitStatus(
"Normally the exit status is 0. In the event of an error the",
"exit status will be one of the below:\n\n",
hl.Sprintf("%d: Invalid option\n", InvalidOption),
hl.Sprintf("%d: Missing option\n", MissingOption),
hl.Sprintf("%d: Invalid argument\n", InvalidArgument),
hl.Sprintf("%d: Missing argument\n", MissingArgument),
hl.Sprintf("%d: Extra argument\n", ExtraArgument),
hl.Sprintf("%d: Exception", Exception),
)
cli.Info = strings.Join(
[]string{
"Easily generate a self-signed CA and issue",
"client/server certificates. To add Subject Alternative",
"Names (SANs), you can append \":alt\" as many times as",
"needed, for example: hostN:alt1...:altN.",
},
" ",
cli.Info(
"Easily generate a self-signed CA and issue client/server",
"certificates. To add Subject Alternative Names (SANs), you",
"can append \":alt\" as many times as needed, for example:",
"hostN:alt1...:altN.",
)
cli.SeeAlso = []string{"openssl"}

Expand Down
2 changes: 1 addition & 1 deletion globals.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ var roFilePerms os.FileMode = os.ModePerm & 0o400
var rwFilePerms os.FileMode = os.ModePerm & 0o600

// Version is the package version.
const Version = "1.4.2"
const Version = "1.4.3"
12 changes: 6 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ module github.com/mjwhitta/pki
go 1.19

require (
github.com/mjwhitta/cli v1.10.1
github.com/mjwhitta/errors v1.0.1
github.com/mjwhitta/hilighter v1.11.2
github.com/mjwhitta/log v1.6.3
github.com/mjwhitta/pathname v1.2.4
github.com/stretchr/testify v1.8.1
github.com/mjwhitta/cli v1.11.0
github.com/mjwhitta/errors v1.0.2
github.com/mjwhitta/hilighter v1.11.3
github.com/mjwhitta/log v1.6.4
github.com/mjwhitta/pathname v1.2.5
github.com/stretchr/testify v1.8.4
)

require (
Expand Down
31 changes: 12 additions & 19 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,33 +1,26 @@
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE=
github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY=
github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
github.com/mjwhitta/cli v1.10.1 h1:Da63yUFyWI8tmyx5L3EH55YRKTE0u6VGFusjxlyzqKc=
github.com/mjwhitta/cli v1.10.1/go.mod h1:65S6kvxR4eYc4IibAI8WxSktIunCZpdet0XaMI2DEws=
github.com/mjwhitta/errors v1.0.1 h1:f12gpCh23cfzXUgtlZBWGs387ZJeEeOemv7hLSvBAx0=
github.com/mjwhitta/errors v1.0.1/go.mod h1:VxHM8bLMPVqkvHiYQq4Nq4sjNqPjUtKLhSF2I0wve5U=
github.com/mjwhitta/hilighter v1.11.2 h1:RKl9BeBjHWNacbQuR3F4yzfUEr1krLwjgFsDI9ZuyZo=
github.com/mjwhitta/hilighter v1.11.2/go.mod h1:0Yzfon7qT8oTfofbA+SGaB21GQshjlOgwDEF6xuCyVc=
github.com/mjwhitta/log v1.6.3 h1:dY0d9duROyuKytPGCZeC7QZvoLxgvnT/Q8nNFT8V4eI=
github.com/mjwhitta/log v1.6.3/go.mod h1:1GbElSBgBrnzGBa6m/tRuOd0E89QnoPSDpmnN7FdtmE=
github.com/mjwhitta/pathname v1.2.4 h1:DMVRSdMuvV2UGoyJ0KIEmzebWezSiVCC3NaEcz8rqM8=
github.com/mjwhitta/pathname v1.2.4/go.mod h1:uNt88tqjIY6UB4h1tl3LozHqF7Gdy24Mh7h6YIn/u8s=
github.com/mjwhitta/cli v1.11.0 h1:Y38x9ZMq6FZMRTcUSJDV35sDu2kAlkz4Nwf4fX9Owww=
github.com/mjwhitta/cli v1.11.0/go.mod h1:NnyhgKZy85L4PVuZBC+gi2b8bSty0lglc/0jyWAHdUw=
github.com/mjwhitta/errors v1.0.2 h1:5QmN4kKfFwYiSsdASDmoi3ie7HesdU7pNDqlhXE9nuU=
github.com/mjwhitta/errors v1.0.2/go.mod h1:VxHM8bLMPVqkvHiYQq4Nq4sjNqPjUtKLhSF2I0wve5U=
github.com/mjwhitta/hilighter v1.11.3 h1:2r6t8CdSU9HUamK73R1RR9jmH+7QYkh8XGFXZetVCyI=
github.com/mjwhitta/hilighter v1.11.3/go.mod h1:/PQ6zrYVQSuX8s9j05nnjQB+kM4+nj3alMYcxyqFAnY=
github.com/mjwhitta/log v1.6.4 h1:lc/7UK9i7hfjVhQSiWhRvgcpqt3X9CoXNGP59bAs06c=
github.com/mjwhitta/log v1.6.4/go.mod h1:/+6cIdTt1mlWG6QNIIXfDdj4Gw0eoPrNEzHEtETiZYQ=
github.com/mjwhitta/pathname v1.2.5 h1:wSUZGv+mCrmndNkX2uak8XMZhkXXbgjYG/dMclGKrUE=
github.com/mjwhitta/pathname v1.2.5/go.mod h1:t0k8GIucdXPKhiKyV4aAWtBA9LhLB7mV50DJlhrMpog=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8=
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw=
github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo=
github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU=
github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk=
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk=
github.com/stretchr/testify v1.8.4/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
6 changes: 3 additions & 3 deletions pki.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func New(root string, cfg *Cfg) (*PKI, error) {
// already exist on disk, they will be parsed and returned instead.
func (p *PKI) CreateCA() (*x509.Certificate, *rsa.PrivateKey, error) {
var e error
var pubkey interface{} // *rsa.PublicKey
var pubkey any // *rsa.PublicKey

// Use existing key, if found, otherwise create
if p.key, e = p.createOrGetKey("ca"); e != nil {
Expand Down Expand Up @@ -158,7 +158,7 @@ func (p *PKI) createCert(
ca *x509.Certificate,
cn string,
csr *x509.CertificateRequest,
pubkey interface{}, // *rsa.PublicKey
pubkey any, // *rsa.PublicKey
certType CertType,
) (*x509.Certificate, error) {
var after time.Time
Expand Down Expand Up @@ -354,7 +354,7 @@ func (p *PKI) CreateCSRFor(
func (p *PKI) createOrGetCert(
cn string,
csr *x509.CertificateRequest,
pubkey interface{}, // *rsa.PublicKey
pubkey any, // *rsa.PublicKey
certType CertType,
) (*x509.Certificate, error) {
var cert *x509.Certificate
Expand Down

0 comments on commit 9236dad

Please sign in to comment.