Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

💡 [REQUEST] - Ability to override "http" as given by plex.tv with "https" #272

Open
2 of 4 tasks
tknmncr opened this issue Nov 9, 2023 · 7 comments
Open
2 of 4 tasks
Labels
answer provided An answer has been provided and is awaiting a response from OP enhancement New feature or request
Milestone

Comments

@tknmncr
Copy link

tknmncr commented Nov 9, 2023

Checks

  • I have searched the existing issue and my feature request does not exist!
  • I have tried out the latest development build and can confirm my feature request is not yet implemented!

Describe the feature

Most of the servers I connect to only listen on https, not http. plex.tv only provides http server addresses, so the majority of the servers I am trying to see fail (most of my friends are network admins, and block non-encrypted traffic at their firewalls). This looks to be related to BUG #252.

I picked one of them and tried to access with curl; as you can see the https one responds appropriately with Unauthorized, but the http one just craps out.

sgarrett@plex:~/src/PlexRipper/src/PlexApi$ curl -k https://xxx.xxx.xxx.xxx:12232
<html><head><script>window.location = window.location.href.match(/(^.+\/)[^\/]*$/)[1] + 'web/index.html';</script><title>Unauthorized</title></head><body><h1>401 Unauthorized</h1></body></html>
sgarrett@plex:~/src/PlexRipper/src/PlexApi$ curl -k http://xxx.xxx.xxx.xxx:12232
curl: (56) Recv failure: Connection reset by peer

Having the ability to override the URL provided from plex.tv with https instead of http should resolve the issues.

Additional information

  • Would you be willing to help implement this feature?
  • Does this feature have a potential to break existing features?
@tknmncr tknmncr added the enhancement New feature or request label Nov 9, 2023
@JasonLandbridge
Copy link
Collaborator

Hey, can you try setting the preferred connection like this:

image

  1. Open the server settings by cliking on the gear icon
  2. Go to Server Connections
  3. Select the https connection

Would this work?

@JasonLandbridge JasonLandbridge added the answer provided An answer has been provided and is awaiting a response from OP label Nov 12, 2023
@JasonLandbridge
Copy link
Collaborator

If the connection selection isn't showing up with the above, then that has been fixed here: #253

@tknmncr
Copy link
Author

tknmncr commented Nov 12, 2023 via email

@JasonLandbridge
Copy link
Collaborator

Can you try this url in your browser and see if the https connection shows up on the page?

https://plex.tv/api/v2/resources?X-Plex-Token={{PLEX_AUTH_TOKEN}}&X-Plex-Client-Identifier=Chrome

Make sure to replace the PLEX_AUTH_TOKEN with your token Plex account token

A quick Google search on "ErrorMessage - The SSL connection could not be established, see inner exception." shows that the server certificate might be invalid:

https://stackoverflow.com/questions/52939211/the-ssl-connection-could-not-be-established

One of the answers talks about disabling the check but that might be a security issue, but that might not matter for PlexRipper. I will need to investigate a bit more.

@frosit
Copy link
Collaborator

frosit commented Nov 12, 2023

Maybe this could help. Usually when I'm working with http requests (curl, guzzle) and I stumble upon an endpoint with an invalid certificate, such thing can be ignored by setting a parameter before you send out your request. Something like allow_insecure->true.

Good chance your http client library or whatever you use raises an exception upon an invalid certificate, which is good but I think many self hosted plex libraries may have improper certificates. So adding a setting to allow insecure requests would be logical, and allow it by default if env=dev?

If I remember correct a problem like this could also be identified by the response http status code or the type of exception so if we would have logs of that we could probably tell if it's a network thing or not. If you tell me where that code is defined and a link to the docs I could help check on that.

@tknmncr
Copy link
Author

tknmncr commented Nov 12, 2023 via email

@frosit
Copy link
Collaborator

frosit commented Nov 14, 2023

Well, I deep a quick dive into the docs of that seems to be our API client, and it does has the option to ignore insecure certificates.

on your case
However, in your case, i think you could be dealing with something weird on your network. I have been experimenting a bit and I can't seem to trigger this issue. Maybe a private network like I use could be a workaround for you.

I raised the following feature request: #278 to allow for custom server URL's to be configured manually so that I could configure wrong SSL certs. It also is very usefull in a lot of other casees to set a custom url., hence the request.

What I found in docs

When doing a bit research I think I found how what change we should make to do this, maybe we could test it a bit on a different branch and see. But I'm not sure where exacty to implement this... (yet).

It seems to be possible to specify a RemoteCertificateValidationCallback while instantiating RestClient in it's constructor. This callback would be like below to allow sslPolicyErrors.

ServicePointManager.ServerCertificateValidationCallback +=
        (sender, certificate, chain, sslPolicyErrors) => true;

Here are the docs: https://restsharp.dev/usage.html#simple-factory

So If you wanted to test it quickly you'd override client somewhere near here?

public PlexApi(ILog log, PlexApiClient client)

But I'd have to brush up on my C# first before doing things like this, I don't know how to properly implement this currently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
answer provided An answer has been provided and is awaiting a response from OP enhancement New feature or request
Projects
Status: No status
Development

No branches or pull requests

3 participants