dsnopek / anki-sync-server

A personal Anki sync server (so you can sync against your own server rather than AnkiWeb)
GNU Affero General Public License v3.0
744 stars 95 forks source link

SSL support #15

Closed agrueneberg closed 10 years ago

agrueneberg commented 10 years ago

Hi David,

I would like to run anki-sync-server over SSL, but pointing SYNC_URL to the HTTPS URL is not enough because Anki does SSL certificate validation and only accepts the certificates for AnkiWeb in ankiweb.certs. Are you aware of any workaround?

-ag

dsnopek commented 10 years ago

Unfortunately, I'm not aware of a work around. :-/ I have my main website over HTTPS but have the Anki server working over plain HTTP.

However, from an Anki plugin you can do pretty much anything! I don't know exactly how to do it, but I'm sure you could include your own certificates and override Anki's defaults.

agrueneberg commented 10 years ago

Anki plugins are powerful, indeed! The following code disables SSL certificate validation:

import anki.sync
import httplib2

HTTP_TIMEOUT = 90
HTTP_PROXY = None

def myHttpCon():
    return httplib2.Http(
        timeout=HTTP_TIMEOUT,
        proxy_info=HTTP_PROXY,
        disable_ssl_certificate_validation=True)

anki.sync.SYNC_URL = 'https://localhost:27701/sync/'
anki.sync.httpCon = myHttpCon
dsnopek commented 10 years ago

Awesome! I'm glad you worked it out and thanks for sharing the solution. :-)