Don't overwrite signing time.
[openssl.git] / crypto / pkcs7 / pk7_doit.c
index 5b803b0266fa5a9a9aef9104bb9891ed87dd7b22..fce4a841a66bbeddddb084fcc915c26715dcb621 100644 (file)
@@ -557,11 +557,15 @@ int PKCS7_dataFinal(PKCS7 *p7, BIO *bio)
                                ASN1_UTCTIME *sign_time;
                                const EVP_MD *md_tmp;
 
-                               /* Add signing time */
-                               sign_time=X509_gmtime_adj(NULL,0);
-                               PKCS7_add_signed_attribute(si,
-                                       NID_pkcs9_signingTime,
-                                       V_ASN1_UTCTIME,sign_time);
+                               /* Add signing time if not already present */
+                               if (!PKCS7_get_signed_attribute(si,
+                                                       NID_pkcs9_signingTime))
+                                       {
+                                       sign_time=X509_gmtime_adj(NULL,0);
+                                       PKCS7_add_signed_attribute(si,
+                                               NID_pkcs9_signingTime,
+                                               V_ASN1_UTCTIME,sign_time);
+                                       }
 
                                /* Add digest */
                                md_tmp=EVP_MD_CTX_md(&ctx_tmp);