install: add support for native ssl command

The code should auto-select the native ssl method if the ssl command is available on the UPS.

If this fails, install will drop back to the original install method used by this tool (which works on NMC2).
This commit is contained in:
Greg T. Wallace 2024-06-06 22:51:12 -04:00
parent 06c9263bc4
commit dda11df624
5 changed files with 77 additions and 14 deletions

View file

@ -31,7 +31,7 @@ func (app *app) cmdCreate(_ context.Context, args []string) error {
// validation done
// make p15 files
apcKeyCertFile, keyFile, err := app.pemToAPCP15s(keyPem, certPem, "create")
keyFile, apcKeyCertFile, err := app.pemToAPCP15(keyPem, certPem, "create")
if err != nil {
return err
}

View file

@ -46,7 +46,7 @@ func (app *app) cmdInstall(cmdCtx context.Context, args []string) error {
// validation done
// make p15 file
keyCertP15, _, err := app.pemToAPCP15s(keyPem, certPem, "install")
keyP15, keyCertP15, err := app.pemToAPCP15(keyPem, certPem, "install")
if err != nil {
return err
}
@ -66,7 +66,7 @@ func (app *app) cmdInstall(cmdCtx context.Context, args []string) error {
}
// install SSL Cert
err = client.InstallSSLCert(keyCertP15)
err = client.InstallSSLCert(keyP15, certPem, keyCertP15)
if err != nil {
return fmt.Errorf("install: failed to send file to ups over scp (%w)", err)
}

View file

@ -5,10 +5,10 @@ import (
"fmt"
)
// pemToAPCP15s reads the specified pem files and returns the apc p15 files (both a
// pemToAPCP15 reads the specified pem files and returns the apc p15 files (both a
// p15 file with just the private key, and also a p15 file with both the private key
// and certificate). The key+cert file includes the required APC header, prepended.
func (app *app) pemToAPCP15s(keyPem, certPem []byte, parentCmdName string) (apcKeyCertFile, keyFile []byte, err error) {
func (app *app) pemToAPCP15(keyPem, certPem []byte, parentCmdName string) (keyFile []byte, apcKeyCertFile []byte, err error) {
app.stdLogger.Printf("%s: making apc p15 file from pem", parentCmdName)
// make p15 struct
@ -36,5 +36,5 @@ func (app *app) pemToAPCP15s(keyPem, certPem []byte, parentCmdName string) (apcK
app.stdLogger.Printf("%s: apc p15 file data succesfully generated", parentCmdName)
return apcKeyCertFile, keyFile, nil
return keyFile, apcKeyCertFile, nil
}