From ec62884649f7af5f0a29346741754590e6de99ce Mon Sep 17 00:00:00 2001 From: Mark McDowall Date: Mon, 6 Dec 2021 20:15:35 -0800 Subject: [PATCH] Fixed: Report certificate validation failures when configuring Plex Media Server connection Closes #4781 --- .../Plex/Server/PlexServerProxy.cs | 7 ++++++- .../Plex/Server/PlexServerService.cs | 17 +++++++++++++---- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/src/NzbDrone.Core/Notifications/Plex/Server/PlexServerProxy.cs b/src/NzbDrone.Core/Notifications/Plex/Server/PlexServerProxy.cs index 2997fcb54..537af484f 100644 --- a/src/NzbDrone.Core/Notifications/Plex/Server/PlexServerProxy.cs +++ b/src/NzbDrone.Core/Notifications/Plex/Server/PlexServerProxy.cs @@ -195,7 +195,12 @@ namespace NzbDrone.Core.Notifications.Plex.Server } catch (WebException ex) { - throw new PlexException("Unable to connect to Plex Media Server", ex); + if (ex.Status == WebExceptionStatus.TrustFailure) + { + throw new PlexException("Unable to connect to Plex Media Server, certificate validation failed.", ex); + } + + throw new PlexException($"Unable to connect to Plex Media Server, {ex.Message}", ex); } return response.Content; diff --git a/src/NzbDrone.Core/Notifications/Plex/Server/PlexServerService.cs b/src/NzbDrone.Core/Notifications/Plex/Server/PlexServerService.cs index 574267f2a..72b50357a 100644 --- a/src/NzbDrone.Core/Notifications/Plex/Server/PlexServerService.cs +++ b/src/NzbDrone.Core/Notifications/Plex/Server/PlexServerService.cs @@ -8,6 +8,7 @@ using NLog; using NzbDrone.Common.Cache; using NzbDrone.Common.Extensions; using NzbDrone.Core.Tv; +using NzbDrone.Core.Validation; namespace NzbDrone.Core.Notifications.Plex.Server { @@ -191,15 +192,23 @@ namespace NzbDrone.Core.Notifications.Plex.Server return new ValidationFailure("Host", "At least one TV library is required"); } } - catch(PlexAuthenticationException ex) + catch (PlexAuthenticationException ex) { - _logger.Error(ex, "Unable to connect to Plex Server"); + _logger.Error(ex, "Unable to connect to Plex Media Server"); return new ValidationFailure("AuthToken", "Invalid authentication token"); } + catch (PlexException ex) + { + return new NzbDroneValidationFailure("Host", ex.Message); + } catch (Exception ex) { - _logger.Error(ex, "Unable to connect to Plex Server"); - return new ValidationFailure("Host", "Unable to connect to Plex Server"); + _logger.Error(ex, "Unable to connect to Plex Media Server"); + + return new NzbDroneValidationFailure("Host", "Unable to connect to Plex Media Server") + { + DetailedDescription = ex.Message + }; } return null;