Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| ee8e48cd56 | |||
| 11866a3b29 |
@@ -1,5 +1,10 @@
|
|||||||
CHANGELOG
|
CHANGELOG
|
||||||
|
|
||||||
|
v1.17.1 - 2025-11-21
|
||||||
|
|
||||||
|
Changed:
|
||||||
|
- certlib: various code cleanups.
|
||||||
|
|
||||||
v1.17.0 - 2025-11-21
|
v1.17.0 - 2025-11-21
|
||||||
|
|
||||||
Added:
|
Added:
|
||||||
|
|||||||
@@ -448,13 +448,13 @@ func encodeCertsToFiles(
|
|||||||
derContent = append(derContent, cert.Raw...)
|
derContent = append(derContent, cert.Raw...)
|
||||||
}
|
}
|
||||||
files = append(files, fileEntry{
|
files = append(files, fileEntry{
|
||||||
name: baseName + ".crt",
|
name: baseName + ".cer",
|
||||||
content: derContent,
|
content: derContent,
|
||||||
})
|
})
|
||||||
} else if len(certs) > 0 {
|
} else if len(certs) > 0 {
|
||||||
// Individual DER file (should only have one cert)
|
// Individual DER file (should only have one cert)
|
||||||
files = append(files, fileEntry{
|
files = append(files, fileEntry{
|
||||||
name: baseName + ".crt",
|
name: baseName + ".cer",
|
||||||
content: certs[0].Raw,
|
content: certs[0].Raw,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -472,17 +472,17 @@ func encodeCertsToFiles(
|
|||||||
derContent = append(derContent, cert.Raw...)
|
derContent = append(derContent, cert.Raw...)
|
||||||
}
|
}
|
||||||
files = append(files, fileEntry{
|
files = append(files, fileEntry{
|
||||||
name: baseName + ".crt",
|
name: baseName + ".cer",
|
||||||
content: derContent,
|
content: derContent,
|
||||||
})
|
})
|
||||||
} else if len(certs) > 0 {
|
} else if len(certs) > 0 {
|
||||||
files = append(files, fileEntry{
|
files = append(files, fileEntry{
|
||||||
name: baseName + ".crt",
|
name: baseName + ".cer",
|
||||||
content: certs[0].Raw,
|
content: certs[0].Raw,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("unsupported encoding: %s (must be 'pem', 'der', or 'both')", encoding)
|
return nil, fmt.Errorf("unsupported encoding: %s (must be 'pem', 'der', 'both', 'crt', 'pemcrt')", encoding)
|
||||||
}
|
}
|
||||||
|
|
||||||
return files, nil
|
return files, nil
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ type Subject struct {
|
|||||||
Province string `yaml:"province"`
|
Province string `yaml:"province"`
|
||||||
Organization string `yaml:"organization"`
|
Organization string `yaml:"organization"`
|
||||||
OrganizationalUnit string `yaml:"organizational_unit"`
|
OrganizationalUnit string `yaml:"organizational_unit"`
|
||||||
Email string `yaml:"email"`
|
Email []string `yaml:"email"`
|
||||||
DNSNames []string `yaml:"dns"`
|
DNSNames []string `yaml:"dns"`
|
||||||
IPAddresses []string `yaml:"ips"`
|
IPAddresses []string `yaml:"ips"`
|
||||||
}
|
}
|
||||||
@@ -92,14 +92,11 @@ func (cs CertificateRequest) Request(priv crypto.PrivateKey) (*x509.CertificateR
|
|||||||
PublicKeyAlgorithm: 0,
|
PublicKeyAlgorithm: 0,
|
||||||
PublicKey: getPublic(priv),
|
PublicKey: getPublic(priv),
|
||||||
Subject: subject,
|
Subject: subject,
|
||||||
|
EmailAddresses: cs.Subject.Email,
|
||||||
DNSNames: cs.Subject.DNSNames,
|
DNSNames: cs.Subject.DNSNames,
|
||||||
IPAddresses: ipAddresses,
|
IPAddresses: ipAddresses,
|
||||||
}
|
}
|
||||||
|
|
||||||
if cs.Subject.Email != "" {
|
|
||||||
req.EmailAddresses = []string{cs.Subject.Email}
|
|
||||||
}
|
|
||||||
|
|
||||||
reqBytes, err := x509.CreateCertificateRequest(rand.Reader, req, priv)
|
reqBytes, err := x509.CreateCertificateRequest(rand.Reader, req, priv)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("failed to create certificate request: %w", err)
|
return nil, fmt.Errorf("failed to create certificate request: %w", err)
|
||||||
@@ -130,7 +127,7 @@ func (cs CertificateRequest) Generate() (crypto.PrivateKey, *x509.CertificateReq
|
|||||||
type Profile struct {
|
type Profile struct {
|
||||||
IsCA bool `yaml:"is_ca"`
|
IsCA bool `yaml:"is_ca"`
|
||||||
PathLen int `yaml:"path_len"`
|
PathLen int `yaml:"path_len"`
|
||||||
KeyUse string `yaml:"key_uses"`
|
KeyUse []string `yaml:"key_uses"`
|
||||||
ExtKeyUsages []string `yaml:"ext_key_usages"`
|
ExtKeyUsages []string `yaml:"ext_key_usages"`
|
||||||
Expiry string `yaml:"expiry"`
|
Expiry string `yaml:"expiry"`
|
||||||
}
|
}
|
||||||
@@ -161,15 +158,17 @@ func (p Profile) templateFromRequest(req *x509.CertificateRequest) (*x509.Certif
|
|||||||
IPAddresses: req.IPAddresses,
|
IPAddresses: req.IPAddresses,
|
||||||
}
|
}
|
||||||
|
|
||||||
var ok bool
|
for _, sku := range p.KeyUse {
|
||||||
certTemplate.KeyUsage, ok = keyUsageStrings[p.KeyUse]
|
ku, ok := keyUsageStrings[sku]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("invalid key usage: %s", p.KeyUse)
|
return nil, fmt.Errorf("invalid key usage: %s", p.KeyUse)
|
||||||
|
}
|
||||||
|
|
||||||
|
certTemplate.KeyUsage |= ku
|
||||||
}
|
}
|
||||||
|
|
||||||
var eku x509.ExtKeyUsage
|
|
||||||
for _, extKeyUsage := range p.ExtKeyUsages {
|
for _, extKeyUsage := range p.ExtKeyUsages {
|
||||||
eku, ok = extKeyUsageStrings[extKeyUsage]
|
eku, ok := extKeyUsageStrings[extKeyUsage]
|
||||||
if !ok {
|
if !ok {
|
||||||
return nil, fmt.Errorf("invalid extended key usage: %s", extKeyUsage)
|
return nil, fmt.Errorf("invalid extended key usage: %s", extKeyUsage)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user