瀏覽代碼

update ValidateSslCertificate

Luke Pulverenti 9 年之前
父節點
當前提交
2f75af8563
共有 1 個文件被更改,包括 5 次插入18 次删除
  1. 5 18
      MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs

+ 5 - 18
MediaBrowser.Server.Implementations/Configuration/ServerConfigurationManager.cs

@@ -188,28 +188,15 @@ namespace MediaBrowser.Server.Implementations.Configuration
         {
             var serverConfig = (ServerConfiguration)newConfig;
 
-            var certPath = serverConfig.CertificatePath;
+            var newPath = serverConfig.CertificatePath;
 
-            if (!string.IsNullOrWhiteSpace(certPath))
+            if (!string.IsNullOrWhiteSpace(newPath)
+                && !string.Equals(Configuration.CertificatePath ?? string.Empty, newPath))
             {
                 // Validate
-                if (!File.Exists(certPath))
-                {
-                    throw new FileNotFoundException(string.Format("Certificate file '{0}' does not exist.", certPath));
-                }
-
-                try
-                {
-                    var cert = new System.Security.Cryptography.X509Certificates.X509Certificate2(certPath);
-
-                    if (cert.PrivateKey == null)
-                    {
-                        throw new ArgumentException("Certificate does not contain a private key!");
-                    }
-                }
-                catch (Exception ex)
+                if (!FileSystem.FileExists(newPath))
                 {
-                    throw new ArgumentException(string.Format("Exception loading certificate: '{0}' - {1}", certPath, ex.Message));
+                    throw new FileNotFoundException(string.Format("Certificate file '{0}' does not exist.", newPath));
                 }
             }
         }