From e0478dcafe40938508897eccabc38f184c49763b Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Mon, 8 Oct 2018 11:45:02 +0200 Subject: [PATCH] Older OpenSSL versions do not accept "-" as input Signed-off-by: Knut Ahlers --- generator_test.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/generator_test.go b/generator_test.go index 54fc399..95c47db 100644 --- a/generator_test.go +++ b/generator_test.go @@ -3,6 +3,8 @@ package dhparam import ( "bytes" "fmt" + "io/ioutil" + "os" "os/exec" "strings" "testing" @@ -21,7 +23,19 @@ func execGeneratorIntegration(t *testing.T, bitsize int, generator Generator) { buf := new(bytes.Buffer) - cmd := exec.Command("openssl", "dhparam", "-inform", "PEM", "-in", "-", "-check", "-noout", "-text") + f, err := ioutil.TempFile("", "dhparam.*") + if err != nil { + t.Fatalf("Unable to create tempfile: %s", err) + } + defer os.Remove(f.Name()) + + if _, err = f.Write(pem); err != nil { + t.Fatalf("Unable to write tempfile: %s", err) + } + + f.Close() + + cmd := exec.Command("openssl", "dhparam", "-inform", "PEM", "-in", f.Name(), "-check", "-noout", "-text") cmd.Stdin = bytes.NewReader(pem) cmd.Stdout = buf cmd.Stderr = buf