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

Support self-signed SSL Certs #13

Closed
gjabell opened this issue Nov 6, 2018 · 21 comments
Closed

Support self-signed SSL Certs #13

gjabell opened this issue Nov 6, 2018 · 21 comments

Comments

@gjabell
Copy link
Contributor

gjabell commented Nov 6, 2018

The Android client doesn't appear to support self-signed SSL certs, which is inconvenient if the server is for internal use. Would it be possible to add an option to ignore self-signed errors, or pull certificates from the user's certificate authority store during certificate validation?

@jmattheis
Copy link
Member

@gjabell Thanks for your issue (:
Yeah it should be possible, later this week I'll have a look at it.

@gjabell
Copy link
Contributor Author

gjabell commented Nov 6, 2018

@jmattheis Sure thing! I might be able to contribute too if you want some extra help.
Looking forward to trying it out!

@jmattheis
Copy link
Member

@gjabell That would be great (:, I myself have not much experience with self-signed certificates and android, so feel free to try it.

@gjabell
Copy link
Contributor Author

gjabell commented Nov 7, 2018

@jmattheis Looks like it isn't too hard to implement, I have some partial implementation already. Would you prefer that we disable SSL validation completely, or ask the user for their self-signed Certificate Authority certificate to use for validation?

@jvandenbroek
Copy link

Does it work at all with SSL? Because I've set up my already issued Letsencrypt certificate (certfile / certkey) and this work fine from the browser, but the Android client keeps returning status code 0. The server prints this log: http: TLS handshake error from 192.168.130.203:44707: remote error: tls: unknown certificate

Sorry for hijacking this thread, but it seems related ;)

@gjabell
Copy link
Contributor Author

gjabell commented Nov 7, 2018

@jvandenbroek All good! Are you connecting to your server from your phone with the IP address or hostname? Also can you list your server config file here (just put placeholders in place of the private information).

@jvandenbroek
Copy link

jvandenbroek commented Nov 7, 2018

@gjabell Alright :) I'm using the hostname which works fine on the browser, so the certificate itself seems to be loaded fine.

My /etc/gotify/config.yml:

server:
  port: 8084 # the port for the http server
  ssl:
    enabled: true # if https should be enabled
    redirecttohttps: true # redirect to https if site is accessed by http
    port: 4444 # the https port
    certfile: /etc/letsencrypt/live/mydomain/cert.pem # the cert file (leave empty when using letsencrypt)
    certkey: /etc/letsencrypt/live/mydomain/privkey.pem # the cert key (leave empty when using letsencrypt)
    letsencrypt:
      enabled: false # if the certificate should be requested from letsencrypt
      accepttos: false # if you accept the tos from letsencrypt
      cache: data/certs # the directory of the cache from letsencrypt
      hosts: # the hosts for which letsencrypt should request certificates
      - mydomain.tld
      - myotherdomain.tld
database: # for database see (configure database section)
  dialect: sqlite3
  connection: data/gotify.db
defaultuser: # on database creation, gotify creates an admin user
  name: admin # the username of the default user
  pass: admin # the password of the default user
passstrength: 10 # the bcrypt password strength (higher = better but also slower)
uploadedimagesdir: data/images # the directory for storing uploaded images

Where 'mydomain' is the correct domain dir I use for all my apps. Running with root (only during testing of course ;)), so no permission issues.

Btw I also tried the default port 443, same issue.
Edit: I'm using the prebuild arm64 binary, maybe has something to do with that?

@gjabell
Copy link
Contributor Author

gjabell commented Nov 7, 2018

@jvandenbroek Ah, ok, I think I know the issue. Letsencrypt should give you multiple files, one is cert.pem and another is fullchain.pem. Fullchain.pem has the entire certificate chain in it, and that's the one you want to use. I just got the same error message as you when testing your config locally, but if I change the certfile line to be /etc/letsencrypt/live/mydomain/fullchain.pem it works for me :) Can you try that out?

@jvandenbroek
Copy link

@gjabell Great, that seems the culprit! Thank you, I could have tested that myself.. Was a bit mislead by the fact it works with only the privkey file when accessing from desktop :)

@jmattheis
Copy link
Member

@gjabell

@jmattheis Looks like it isn't too hard to implement, I have some partial implementation already. Would you prefer that we disable SSL validation completely, or ask the user for their self-signed Certificate Authority certificate to use for validation?

It would be great to support both, I guess adding the self-signed certificate would be more secure than just disabling it.

@gjabell
Copy link
Contributor Author

gjabell commented Nov 7, 2018

@jvandenbroek Glad to hear it :) yeah it's a bit confusing, I think in browser the cert is enough to prove that it's from letsencrypt but I guess if you're accessing it from android you need the full chain.

@jmattheis Yeah that's a good point. I guess I can just add some options to the login screen to either disable SSL validation for the current login or select a certificate authority file from the filesystem?

@gjabell
Copy link
Contributor Author

gjabell commented Nov 7, 2018

@jmattheis Alright, just opened a merge request in #15 :) sorry there are so many changes. If you want me to explain any of the changes I made or want something done differently just let me know. I tested it using both my self-signed cert and also a LetsEncrypt cert and didn't have any issues, but if you find anything not working let me know and I'll fix it.

@jmattheis
Copy link
Member

@gjabell Thanks! I'll have a look at it in the afternoon.

@Leopere
Copy link

Leopere commented Nov 10, 2018

It's pretty trivial to setup a Traefik reverse proxy with automatic LetsEncrypt provisioning if you deploy via docker.

@jmattheis
Copy link
Member

@Leopere Yup, but if Gotify is hosted inside an internal network then letsencrypt is not an option cause it shouldn't be visible to the outside.

@Leopere
Copy link

Leopere commented Nov 10, 2018 via email

@gjabell
Copy link
Contributor Author

gjabell commented Nov 10, 2018

It's possible, just more work than using a self-signed CA especially if you are provisioning lots of clients. You can also run into rate-limit issues if you have many certificates to issue.

@Leopere
Copy link

Leopere commented Nov 10, 2018 via email

@gjabell
Copy link
Contributor Author

gjabell commented Nov 10, 2018

It depends on the context, obviously since I'm running all of my services for myself, using SSL/TLS for internal networks is a bit overkill (gotta get that green lock though!), but in a corporate setting it's equally as important to encrypt internal as external traffic.

@Leopere
Copy link

Leopere commented Nov 10, 2018 via email

@jmattheis
Copy link
Member

Done in #15

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

4 participants