Skip to content

Instantly share code, notes, and snippets.

@tpraxl
Created August 8, 2019 20:33
Show Gist options
  • Save tpraxl/00eff9d9bacbdc22a753fe36d6a1f3e0 to your computer and use it in GitHub Desktop.
Save tpraxl/00eff9d9bacbdc22a753fe36d6a1f3e0 to your computer and use it in GitHub Desktop.
Installing a self-signed certificate on ubports for access to nextcloud

Installing a self-signed certificate on ubports

For my intranet-only nextcloud installation, I have generated a self-signed certificate:

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/ssl/nextcloud.key -out /etc/nginx/ssl/nextcloud.crt

I'm running ubports 16.04 stable on a nexus 5.

Accounts -> Nextcloud won't accept the internal IP in the form https://192.168.2.300. The error message is: host URI invalid.

I can access the web interface using the morph browser after confirming to use the untrusted connection.

Install a self-signed certificate on your ubports phone

Removing the read only protection

First you need to make the relevant paths (temporarily) writable. Otherwise you will end up with the error message mkdir: cannot create directory ‘/etc/ca-certificates/extra’: Read-only file system.

Either remount everything rw, as adviced here: sudo mount -o remount,rw / and reboot as soon as you're done and want get read only protection back.

Or sudo touch /userdata/.writable_image && sudo reboot (to restore read only mode, sudo rm /userdata/.writable_image.

Install the certificate

Login to your phone terminal (either via terminal app, via adb or via ssh.

Fetch the *.crt file from your nextcloud server (e.g. scp user@192.168.2.300:/etc/nginx/ssl/nextcloud.crt ./).

$ sudo mkdir /usr/share/ca-certificates/extra
$ sudo cp nextcloud.crt /usr/share/ca-certificates/extra/
$ dpkg-reconfigure ca-certificates
# In the following dialog choose "ask" and select your new certificate after proceeding
$ sudo update-ca-certificates
$ sudo reboot

The error message host URI invalid will not appear anymore when adding your Nextcloud Account.

Aknowledgements

These articles have also been helpful:

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