Skip to content

Commit c8bdae0

Browse files
authored
Merge pull request ghostunnel#665 from ghostunnel/claude/remove-dead-code-2XK7F
Remove dead code from certloader/internal/test
2 parents 61e1d92 + f85dc3f commit c8bdae0

3 files changed

Lines changed: 0 additions & 114 deletions

File tree

certloader/internal/test/pem.go

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package spiffetest
22

33
import (
4-
"crypto"
54
"crypto/x509"
65
"encoding/pem"
76
"errors"
@@ -31,45 +30,6 @@ func ParseCertificates(certsBytes []byte) ([]*x509.Certificate, error) {
3130
return certs, nil
3231
}
3332

34-
func ParsePrivateKey(keyBytes []byte) (crypto.PrivateKey, error) {
35-
objects, err := parseBlocks(keyBytes, keyType)
36-
if err != nil {
37-
return nil, err
38-
}
39-
if len(objects) == 0 {
40-
return nil, nil
41-
}
42-
43-
privateKey, ok := objects[0].(crypto.PrivateKey)
44-
if !ok {
45-
return nil, fmt.Errorf("expected crypto.PrivateKey; got %T", objects[0])
46-
}
47-
return privateKey, nil
48-
}
49-
50-
func EncodePKCS8PrivateKey(privateKey any) ([]byte, error) {
51-
keyBytes, err := x509.MarshalPKCS8PrivateKey(privateKey)
52-
if err != nil {
53-
return nil, err
54-
}
55-
56-
return pem.EncodeToMemory(&pem.Block{
57-
Type: keyType,
58-
Bytes: keyBytes,
59-
}), nil
60-
}
61-
62-
func EncodeCertificates(certificates []*x509.Certificate) []byte {
63-
pemBytes := []byte{}
64-
for _, cert := range certificates {
65-
pemBytes = append(pemBytes, pem.EncodeToMemory(&pem.Block{
66-
Type: certType,
67-
Bytes: cert.Raw,
68-
})...)
69-
}
70-
return pemBytes
71-
}
72-
7333
func parseBlocks(blocksBytes []byte, expectedType string) ([]any, error) {
7434
objects := []any{}
7535
var foundBlocks = false

certloader/internal/test/util.go

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,37 +13,6 @@ func NewCertPool(certs []*x509.Certificate) *x509.CertPool {
1313
return pool
1414
}
1515

16-
// CopyX509Authorities copies a slice of X.509 certificates to a new slice.
17-
func CopyX509Authorities(x509Authorities []*x509.Certificate) []*x509.Certificate {
18-
copiedX509Authorities := make([]*x509.Certificate, len(x509Authorities))
19-
copy(copiedX509Authorities, x509Authorities)
20-
21-
return copiedX509Authorities
22-
}
23-
24-
// CertsEqual returns true if the slices of X.509 certificates are equal.
25-
func CertsEqual(a, b []*x509.Certificate) bool {
26-
if len(a) != len(b) {
27-
return false
28-
}
29-
30-
for i, cert := range a {
31-
if !cert.Equal(b[i]) {
32-
return false
33-
}
34-
}
35-
36-
return true
37-
}
38-
39-
func RawCertsFromCerts(certs []*x509.Certificate) [][]byte {
40-
rawCerts := make([][]byte, 0, len(certs))
41-
for _, cert := range certs {
42-
rawCerts = append(rawCerts, cert.Raw)
43-
}
44-
return rawCerts
45-
}
46-
4716
func ConcatRawCertsFromCerts(certs []*x509.Certificate) []byte {
4817
var rawCerts []byte
4918
for _, cert := range certs {

certloader/internal/test/workload_api_windows.go

Lines changed: 0 additions & 43 deletions
This file was deleted.

0 commit comments

Comments
 (0)