Sicos1977 / MSGReader

C# Outlook MSG file reader without the need for Outlook
http://sicos1977.github.io/MSGReader
MIT License
493 stars 168 forks source link

Extract the digital signature from msg #403

Closed advanced373 closed 6 months ago

advanced373 commented 6 months ago

I want to extract the signed data from msg, update a property of signed attribute and resign. I can, somehow be able to access the digital signature?

Sicos1977 commented 6 months ago

It is an MSGReader... not a writer. You only can read the sigature not change and rewrite it.

You can get the signing information from these properties

        /// <summary>
        ///     Returns true when the signature is valid when the <see cref="MessageType" /> is a
        ///     <see cref="MessageType.EmailEncryptedAndMaybeSigned" />.
        ///     It will return <c>null</c> when the signature is invalid or the <see cref="Storage.Message" /> has another
        ///     <see cref="MessageType" />
        /// </summary>
        public bool? SignatureIsValid { get; private set; }

        /// <summary>
        ///     Returns the name of the person who signed the <see cref="Storage.Message" /> when the <see cref="MessageType" /> is
        ///     a
        ///     <see cref="MessageType.EmailEncryptedAndMaybeSigned" />. It will return <c>null</c> when the signature is invalid
        ///     or the <see cref="Storage.Message" />
        ///     has another <see cref="MessageType" />
        /// </summary>
        public string SignedBy { get; private set; }

        /// <summary>
        ///     Returns the date and time when the <see cref="Storage.Message" /> has been signed when the
        ///     <see cref="MessageType" /> is a
        ///     <see cref="MessageType.EmailEncryptedAndMaybeSigned" />. It will return <c>null</c> when the signature is invalid
        ///     or the <see cref="Storage.Message" />
        ///     has another <see cref="MessageType" />
        /// </summary>
        public DateTime? SignedOn { get; private set; }

        /// <summary>
        ///     Returns the certificate that has been used to sign the <see cref="Storage.Message" /> when the
        ///     <see cref="MessageType" /> is a
        ///     <see cref="MessageType.EmailEncryptedAndMaybeSigned" />. It will return <c>null</c> when the signature is invalid
        ///     or the <see cref="Storage.Message" />
        ///     has another <see cref="MessageType" />
        /// </summary>
        public X509Certificate2 SignedCertificate { get; private set; }