-
Notifications
You must be signed in to change notification settings - Fork 517
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: support p12 certificate format #415
base: master
Are you sure you want to change the base?
Changes from all commits
95fbe59
8060fff
6f4f86d
0ade6c1
a0139c0
99e57ce
f5e7213
bba2985
559de63
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,3 +2,4 @@ dist/ | |
.idea/ | ||
VERSION | ||
.tmp/ | ||
*.swp | ||
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package lib | ||
|
||
import ( | ||
"strings" | ||
) | ||
|
||
func NewCertificateKeyFormat(fileFormat string) CertificateKeyFormat { | ||
fileFormat = strings.ToUpper(fileFormat) | ||
switch fileFormat { | ||
case "": | ||
return CertKeyFormatNONE | ||
case "PEM": | ||
return CertKeyFormatPEM | ||
case "DER": | ||
return CertKeyFormatDER | ||
case "JCEKS": | ||
return CertKeyFormatJCEKS | ||
case "PKCS12", "P12": | ||
return CertKeyFormatPKCS12 | ||
default: | ||
return CertKeyFormatNONE | ||
} | ||
} | ||
|
||
type CertificateKeyFormat string | ||
|
||
const ( | ||
CertKeyFormatNONE CertificateKeyFormat = "" | ||
// The file contains plain-text PEM data | ||
CertKeyFormatPEM CertificateKeyFormat = "PEM" | ||
// The file contains X.509 DER encoded data | ||
CertKeyFormatDER CertificateKeyFormat = "DER" | ||
// The file contains JCEKS keystores | ||
CertKeyFormatJCEKS CertificateKeyFormat = "JCEKS" | ||
// The file contains PFX data describing PKCS#12 | ||
CertKeyFormatPKCS12 CertificateKeyFormat = "PKCS12" | ||
) | ||
|
||
func (f *CertificateKeyFormat) Set(fileFormat string) { | ||
*f = NewCertificateKeyFormat(fileFormat) | ||
} | ||
|
||
func (f CertificateKeyFormat) IsNone() bool { | ||
return f == CertKeyFormatNONE | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This seems misleading.. these are called There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both JCEKS and PKCS12 formats include both key and certificate files. The key file can also be in DER format, but its usage frequency is low, so it is currently not supported. I am not using the JCEKS format at the moment and haven't tested it, so the code for it is included but not made available for public use. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what's this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"swp" files are temporary files generated by the vim.