mirror of
https://github.com/gregtwallace/apc-p15-tool.git
synced 2025-01-22 08:14:08 +00:00
create: always produce both p15 files
This commit is contained in:
parent
dda11df624
commit
ce9958e422
2 changed files with 13 additions and 21 deletions
|
@ -48,6 +48,12 @@ func (app *app) cmdCreate(_ context.Context, args []string) error {
|
||||||
}
|
}
|
||||||
|
|
||||||
// write file(s)
|
// write file(s)
|
||||||
|
err = os.WriteFile(keyFileName, keyFile, 0600)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("create: failed to write apc p15 key file (%s)", err)
|
||||||
|
}
|
||||||
|
app.stdLogger.Printf("create: apc p15 key file %s written to disk", keyFileName)
|
||||||
|
|
||||||
err = os.WriteFile(keyCertFileName, apcKeyCertFile, 0600)
|
err = os.WriteFile(keyCertFileName, apcKeyCertFile, 0600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("create: failed to write apc p15 key+cert file (%s)", err)
|
return fmt.Errorf("create: failed to write apc p15 key+cert file (%s)", err)
|
||||||
|
@ -57,6 +63,13 @@ func (app *app) cmdCreate(_ context.Context, args []string) error {
|
||||||
// if debug, write additional debug files (b64 format to make copy/paste into asn1 decoder
|
// if debug, write additional debug files (b64 format to make copy/paste into asn1 decoder
|
||||||
// easy to do e.g., https://lapo.it/asn1js)
|
// easy to do e.g., https://lapo.it/asn1js)
|
||||||
if app.config.debugLogging != nil && *app.config.debugLogging {
|
if app.config.debugLogging != nil && *app.config.debugLogging {
|
||||||
|
keyFileNameDebug := keyFileName + ".b64"
|
||||||
|
err = os.WriteFile(keyFileNameDebug, []byte(base64.StdEncoding.EncodeToString(keyFile)), 0600)
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("create: failed to write apc p15 key file (%s)", err)
|
||||||
|
}
|
||||||
|
app.debugLogger.Printf("create: apc p15 key file %s written to disk", keyFileNameDebug)
|
||||||
|
|
||||||
keyCertFileNameDebug := keyCertFileName + ".noheader.b64"
|
keyCertFileNameDebug := keyCertFileName + ".noheader.b64"
|
||||||
err = os.WriteFile(keyCertFileNameDebug, []byte(base64.StdEncoding.EncodeToString(apcKeyCertFile[apcHeaderLen:])), 0600)
|
err = os.WriteFile(keyCertFileNameDebug, []byte(base64.StdEncoding.EncodeToString(apcKeyCertFile[apcHeaderLen:])), 0600)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -73,24 +86,5 @@ func (app *app) cmdCreate(_ context.Context, args []string) error {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// make key p15 ?
|
|
||||||
if app.config.create.makeKeyP15 != nil && *app.config.create.makeKeyP15 {
|
|
||||||
err = os.WriteFile(keyFileName, keyFile, 0600)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("create: failed to write apc p15 key file (%s)", err)
|
|
||||||
}
|
|
||||||
app.stdLogger.Printf("create: apc p15 key file %s written to disk", keyFileName)
|
|
||||||
|
|
||||||
// debug file ?
|
|
||||||
if app.config.debugLogging != nil && *app.config.debugLogging {
|
|
||||||
keyFileNameDebug := keyFileName + ".b64"
|
|
||||||
err = os.WriteFile(keyFileNameDebug, []byte(base64.StdEncoding.EncodeToString(keyFile)), 0600)
|
|
||||||
if err != nil {
|
|
||||||
return fmt.Errorf("create: failed to write apc p15 key file (%s)", err)
|
|
||||||
}
|
|
||||||
app.debugLogger.Printf("create: apc p15 key file %s written to disk", keyFileNameDebug)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,6 @@ type config struct {
|
||||||
create struct {
|
create struct {
|
||||||
keyCertPemCfg
|
keyCertPemCfg
|
||||||
outFilePath *string
|
outFilePath *string
|
||||||
makeKeyP15 *bool
|
|
||||||
outKeyFilePath *string
|
outKeyFilePath *string
|
||||||
}
|
}
|
||||||
install struct {
|
install struct {
|
||||||
|
@ -74,7 +73,6 @@ func (app *app) getConfig(args []string) error {
|
||||||
cfg.create.keyPem = createFlags.StringLong("keypem", "", "string of the rsa-1024 or rsa-2048 key in pem format")
|
cfg.create.keyPem = createFlags.StringLong("keypem", "", "string of the rsa-1024 or rsa-2048 key in pem format")
|
||||||
cfg.create.certPem = createFlags.StringLong("certpem", "", "string of the certificate in pem format")
|
cfg.create.certPem = createFlags.StringLong("certpem", "", "string of the certificate in pem format")
|
||||||
cfg.create.outFilePath = createFlags.StringLong("outfile", createDefaultOutFilePath, "path and filename to write the key+cert p15 file to")
|
cfg.create.outFilePath = createFlags.StringLong("outfile", createDefaultOutFilePath, "path and filename to write the key+cert p15 file to")
|
||||||
cfg.create.makeKeyP15 = createFlags.BoolLong("keyp15", "create a second p15 file with just the private key")
|
|
||||||
cfg.create.outKeyFilePath = createFlags.StringLong("outkeyfile", createDefaultOutKeyFilePath, "path and filename to write the key p15 file to")
|
cfg.create.outKeyFilePath = createFlags.StringLong("outkeyfile", createDefaultOutKeyFilePath, "path and filename to write the key p15 file to")
|
||||||
|
|
||||||
createCmd := &ff.Command{
|
createCmd := &ff.Command{
|
||||||
|
|
Loading…
Reference in a new issue