From f290ec6677c93762544d76dbffd8147eb092a5b4 Mon Sep 17 00:00:00 2001 From: Jeff Schilling Date: Tue, 12 Jan 2010 10:37:36 -0500 Subject: [PATCH] Added checking on private key format, only munge if header and trailer aren't already there --- version-new.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/version-new.php b/version-new.php index 842bfd0..5449459 100644 --- a/version-new.php +++ b/version-new.php @@ -56,7 +56,9 @@ function sign_file($filename, $keydata) file_put_contents($tmp_file, $binary_hash); $key_tmp_file = tempnam('/tmp', 'bar'); - file_put_contents($key_tmp_file, "-----BEGIN DSA PRIVATE KEY-----\n" . $keydata . "\n-----END DSA PRIVATE KEY-----\n"); + if (strpos($keydata,"-----BEGIN DSA PRIVATE KEY-----\n") != 0) + $keydata = "-----BEGIN DSA PRIVATE KEY-----\n" . $keydata . "\n-----END DSA PRIVATE KEY-----\n"; + file_put_contents($key_tmp_file, $keydata); $signed_data = shell_exec("openssl dgst -dss1 -sign $key_tmp_file < $hash_tmp_file");