mirror of
https://github.com/Luzifer/envrun.git
synced 2024-12-20 18:31:17 +00:00
Update OpenSSL library, add CLI support for openssl-sha256
Signed-off-by: Knut Ahlers <knut@ahlers.me>
This commit is contained in:
parent
9315fca1ea
commit
7b474991d6
3 changed files with 17 additions and 6 deletions
|
@ -25,6 +25,10 @@
|
|||
# unused-packages = true
|
||||
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/Luzifer/go-openssl"
|
||||
version = "3.0.0"
|
||||
|
||||
[[constraint]]
|
||||
name = "github.com/Luzifer/rconfig"
|
||||
version = "1.1.0"
|
||||
|
|
|
@ -6,9 +6,10 @@ import (
|
|||
"io"
|
||||
"io/ioutil"
|
||||
|
||||
openssl "github.com/Luzifer/go-openssl"
|
||||
"golang.org/x/crypto/openpgp"
|
||||
"golang.org/x/crypto/openpgp/armor"
|
||||
|
||||
openssl "github.com/Luzifer/go-openssl"
|
||||
)
|
||||
|
||||
type decryptMethod func(body []byte, passphrase string) ([]byte, error)
|
||||
|
@ -20,7 +21,10 @@ func decryptMethodFromName(name string) (decryptMethod, error) {
|
|||
return decryptGPGSymmetric, nil
|
||||
|
||||
case "openssl-md5":
|
||||
return decryptOpenSSLMD5, nil
|
||||
return decryptOpenSSL(openssl.DigestMD5Sum), nil
|
||||
|
||||
case "openssl-sha256":
|
||||
return decryptOpenSSL(openssl.DigestSHA256Sum), nil
|
||||
|
||||
default:
|
||||
return nil, fmt.Errorf("Decrypt method %q not found", name)
|
||||
|
@ -56,6 +60,8 @@ func decryptGPGSymmetric(body []byte, passphrase string) ([]byte, error) {
|
|||
return ioutil.ReadAll(md.UnverifiedBody)
|
||||
}
|
||||
|
||||
func decryptOpenSSLMD5(body []byte, passphrase string) ([]byte, error) {
|
||||
return openssl.New().DecryptString(cfg.Password, string(body))
|
||||
func decryptOpenSSL(kdf openssl.DigestFunc) decryptMethod {
|
||||
return func(body []byte, passphrase string) ([]byte, error) {
|
||||
return openssl.New().DecryptBytes(cfg.Password, body, kdf)
|
||||
}
|
||||
}
|
||||
|
|
5
main.go
5
main.go
|
@ -7,14 +7,15 @@ import (
|
|||
"os/exec"
|
||||
"strings"
|
||||
|
||||
"github.com/Luzifer/rconfig"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/Luzifer/rconfig"
|
||||
)
|
||||
|
||||
var (
|
||||
cfg = struct {
|
||||
CleanEnv bool `flag:"clean" default:"false" description:"Do not pass current environment to child process"`
|
||||
EncryptionMethod string `flag:"encryption" default:"openssl-md5" description:"Encryption method used for encrypted env-file (Available: gpg-symmetric, openssl-md5)"`
|
||||
EncryptionMethod string `flag:"encryption" default:"openssl-md5" description:"Encryption method used for encrypted env-file (Available: gpg-symmetric, openssl-md5, openssl-sha256)"`
|
||||
EnvFile string `flag:"env-file" default:".env" description:"Location of the environment file"`
|
||||
LogLevel string `flag:"log-level" default:"info" description:"Log level (debug, info, warn, error, fatal)"`
|
||||
PasswordFile string `flag:"password-file" default:"" description:"Read encryption key from file"`
|
||||
|
|
Loading…
Reference in a new issue