mirror of
https://github.com/gregtwallace/apc-p15-tool.git
synced 2025-10-09 22:05:39 +00:00
app: add compatibility warnings
Try to warn users in console output about possible certificate issues. fixes: https://github.com/gregtwallace/apc-p15-tool/issues/20
This commit is contained in:
parent
7319fc16d8
commit
b821002e85
5 changed files with 152 additions and 19 deletions
pkg/pkcs15
|
@ -10,8 +10,8 @@ import (
|
|||
// pkcs15KeyCert holds the data for a key and certificate pair; it provides
|
||||
// various methods to transform pkcs15 data
|
||||
type pkcs15KeyCert struct {
|
||||
Cert *x509.Certificate
|
||||
key crypto.PrivateKey
|
||||
cert *x509.Certificate
|
||||
// store the encrypted enveloped Private Key for re-use
|
||||
envelopedPrivateKey []byte
|
||||
}
|
||||
|
@ -32,6 +32,31 @@ const (
|
|||
KeyTypeUnknown
|
||||
)
|
||||
|
||||
// String returns the private key type in a log friendly string format.
|
||||
func (keyType KeyType) String() string {
|
||||
switch keyType {
|
||||
case KeyTypeRSA1024:
|
||||
return "RSA 1024-bit"
|
||||
case KeyTypeRSA2048:
|
||||
return "RSA 2048-bit"
|
||||
case KeyTypeRSA3072:
|
||||
return "RSA 3072-bit"
|
||||
case KeyTypeRSA4096:
|
||||
return "RSA 4096-bit"
|
||||
|
||||
case KeyTypeECP256:
|
||||
return "ECDSA P-256"
|
||||
case KeyTypeECP384:
|
||||
return "ECDSA P-384"
|
||||
case KeyTypeECP521:
|
||||
return "ECDSA P-521"
|
||||
|
||||
default:
|
||||
}
|
||||
|
||||
return "unknown key type"
|
||||
}
|
||||
|
||||
// KeyType returns the private key type
|
||||
func (p15 *pkcs15KeyCert) KeyType() KeyType {
|
||||
switch pKey := p15.key.(type) {
|
||||
|
@ -85,7 +110,7 @@ func ParsePEMToPKCS15(keyPem, certPem []byte) (*pkcs15KeyCert, error) {
|
|||
// create p15 struct
|
||||
p15 := &pkcs15KeyCert{
|
||||
key: key,
|
||||
cert: cert,
|
||||
Cert: cert,
|
||||
}
|
||||
|
||||
// pre-calculate encrypted envelope
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue