diff options
Diffstat (limited to 'mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs')
-rw-r--r-- | mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs | 23 |
1 files changed, 17 insertions, 6 deletions
diff --git a/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs b/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs index af5722f601d..5d3f9dd8177 100644 --- a/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs +++ b/mcs/class/corlib/System.Security.Cryptography.X509Certificates/X509Certificate.cs @@ -116,15 +116,26 @@ namespace System.Security.Cryptography.X509Certificates { [MonoTODO ("Incomplete - minimal validation in this version")] public static X509Certificate CreateFromSignedFile (string filename) { - AuthenticodeDeformatter a = new AuthenticodeDeformatter (filename); - if (a.SigningCertificate != null) { - return new X509Certificate (a.SigningCertificate.RawData); - } - else { + try { + AuthenticodeDeformatter a = new AuthenticodeDeformatter (filename); + if (a.SigningCertificate != null) { + if (a.Reason != 0) { + string msg = String.Format (Locale.GetText ( + "Invalid digital signature on {0}, reason #{1}."), + filename, a.Reason); + throw new COMException (msg); + } + return new X509Certificate (a.SigningCertificate.RawData); + } + // if no signature is present return an empty certificate byte[] cert = null; // must not confuse compiler about null ;) return new X509Certificate (cert); } + catch (Exception e) { + string msg = String.Format (Locale.GetText ("Couldn't extract digital signature from {0}."), filename); + throw new COMException (msg, e); + } } // constructors @@ -410,4 +421,4 @@ namespace System.Security.Cryptography.X509Certificates { } #endif } -}
\ No newline at end of file +} |