From f941fd42de2966686301ceb657bd10b89febea08 Mon Sep 17 00:00:00 2001 From: Adrian Sampson Date: Mon, 2 Jan 2017 20:39:10 -0500 Subject: [PATCH] Always use SSL on servers that don't require SNI I did a little audit using the `openssl` command-line tool to find the servers that don't require SNI. Here's what I found: icbrainz.org: SNI images.weserv.nl: inconclusive, but docs say yes SNI coverartarchive.org: SNI webservice.fanart.tv: *no* SNI dbpedia.org: *no* SNI en.wikipedia.org: *no* SNI ws.audioscrobbler.com: *no* SNI api.microsofttranslator.com: *no* SNI In summary, *only* MusicBrainz and CoverArtArchive were found to require SNI. So I'm using SSL unconditionally on all the other sites. --- beetsplug/fetchart.py | 13 +++---------- beetsplug/lastimport.py | 6 +----- beetsplug/lyrics.py | 5 +---- 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/beetsplug/fetchart.py b/beetsplug/fetchart.py index 855a1df10..d87a5dc48 100644 --- a/beetsplug/fetchart.py +++ b/beetsplug/fetchart.py @@ -398,10 +398,7 @@ class GoogleImages(RemoteArtSource): class FanartTV(RemoteArtSource): """Art from fanart.tv requested using their API""" NAME = u"fanart.tv" - if util.SNI_SUPPORTED: - API_URL = 'https://webservice.fanart.tv/v3/' - else: - API_URL = 'https://webservice.fanart.tv/v3/' + API_URL = 'https://webservice.fanart.tv/v3/' API_ALBUMS = API_URL + 'music/albums/' PROJECT_KEY = '61a7d0ab4e67162b7a0c7c35915cd48e' @@ -494,12 +491,8 @@ class ITunesStore(RemoteArtSource): class Wikipedia(RemoteArtSource): NAME = u"Wikipedia (queried through DBpedia)" - if util.SNI_SUPPORTED: - DBPEDIA_URL = 'https://dbpedia.org/sparql' - WIKIPEDIA_URL = 'https://en.wikipedia.org/w/api.php' - else: - DBPEDIA_URL = 'http://dbpedia.org/sparql' - WIKIPEDIA_URL = 'http://en.wikipedia.org/w/api.php' + DBPEDIA_URL = 'https://dbpedia.org/sparql' + WIKIPEDIA_URL = 'https://en.wikipedia.org/w/api.php' SPARQL_QUERY = u'''PREFIX rdf: PREFIX dbpprop: PREFIX owl: diff --git a/beetsplug/lastimport.py b/beetsplug/lastimport.py index 238e447bc..d7b84b0aa 100644 --- a/beetsplug/lastimport.py +++ b/beetsplug/lastimport.py @@ -17,17 +17,13 @@ from __future__ import division, absolute_import, print_function import pylast from pylast import TopItem, _extract, _number -from beets import util from beets import ui from beets import dbcore from beets import config from beets import plugins from beets.dbcore import types -if util.SNI_SUPPORTED: - API_URL = 'https://ws.audioscrobbler.com/2.0/' -else: - API_URL = 'http://ws.audioscrobbler.com/2.0/' +API_URL = 'https://ws.audioscrobbler.com/2.0/' class LastImportPlugin(plugins.BeetsPlugin): diff --git a/beetsplug/lyrics.py b/beetsplug/lyrics.py index feab2180e..bce95759e 100644 --- a/beetsplug/lyrics.py +++ b/beetsplug/lyrics.py @@ -50,7 +50,6 @@ except ImportError: pass from beets import plugins -from beets import util from beets import ui @@ -646,12 +645,10 @@ class LyricsPlugin(plugins.BeetsPlugin): for source in sources] def get_bing_access_token(self): - url = "{0}api.microsofttranslator.com" params = { 'client_id': 'beets', 'client_secret': self.config['bing_client_secret'], - 'scope': url.format('https://') if util.SNI_SUPPORTED - else url.format('http://'), + 'scope': "https://api.microsofttranslator.com", 'grant_type': 'client_credentials', }