Skip to content

Latest commit

 

History

32 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 

Repository files navigation

vaultwarden_HTTPS_local

This tutorial shows how to run a Vaultwarden installation encrypted only on your own network with iOS integration.

I use a Raspberry Pi 3 and a Intel NUC (Ubuntu Server), but also works on other devices.

My username is pi, when your name is not pi change pi in the follow commands

Type in:

  1. cd /home/pi
  2. mkdir Docker/ssl
  3. cd Docker/ssl
  4. Create a CA key (your own little on-premise Certificate Authority):
openssl genpkey -algorithm RSA -aes128 -out private-ca.key -outform PEM -pkeyopt rsa_keygen_bits:2048

Now answer the questions. Actually, it doesn't matter what you enter here. The only thing that matters here is Common Name. You can also use another Common Name like vaultwarden.com or mypassword.com

  1. Create a CA certificate:
openssl req -x509 -new -nodes -sha256 -days 3650 -key private-ca.key -out self-signed-ca-cert.crt

Note: the -nodes argument prevents setting a pass-phrase for the private key (key pair) in a test/safe environment, otherwise you'll have to input the pass-phrase every time you start/restart the server.

  1. Create a bitwarden key:
openssl genpkey -algorithm RSA -out bitwarden.key -outform PEM -pkeyopt rsa_keygen_bits:2048
  1. Create the bitwarden certificate request file:
openssl req -new -key bitwarden.key -out bitwarden.csr
  1. Now create a new text file with nano bitwarden.ext
authorityKeyIdentifier=keyid,issuer
basicConstraints=CA:FALSE
keyUsage = digitalSignature, nonRepudiation, keyEncipherment, dataEncipherment
extendedKeyUsage = serverAuth
subjectAltName = @alt_names

[alt_names]
DNS.1 = vaultwarden.de
DNS.2 = www.vaultwarden.de

Bildschirmfoto 2021-10-03 um 10 35 00

  1. Save the file with CMD+X, accept with Y+ENTER (or J+ENTER)

  2. Create the bitwarden certificate, signed from the root CA:

openssl x509 -req -in bitwarden.csr -CA self-signed-ca-cert.crt -CAkey private-ca.key -CAcreateserial -out bitwarden.crt -days 365 -sha256 -extfile bitwarden.ext

Note: As of April 2019 iOS 13+ and macOS 15+, the server certificate can not have an expiry > 825 and must include ExtendedKeyUsage extension https://support.apple.com/en-us/HT210176

I use 365 Days.

11. Now we can create a Docker Compose File:

version: '3'

services:
  vaultwarden:
    image: vaultwarden/server:latest
    container_name: vaultwarden
    environment:
      ROCKET_TLS: '{certs="/ssl/bitwarden.crt",key="/ssl/bitwarden.key"}'
      ADMIN_TOKEN: your_own_token
    volumes:
      - /home/pi/Docker/ssl/:/ssl/
      - bw-data:/data/
    ports:
      - "4430:80"
    restart: unless-stopped

volumes:
  bw-data:

I use Portainer to control Docker: Bildschirmfoto 2024-02-14 um 17 49 00

  1. Now you need to set up a local dns forwarding. Some routers can do this. But you can also use a Pi-hole or AdGuard system. If you now enter vaultwarden.de in the local network, you will not land on the vaultwarden.de website but will be redirected to our local Vaultwarden instance. This step is necessary for iOS to accept our self generated certificate.

Bildschirmfoto 2021-10-03 um 11 00 16

  1. Start the browser and open
https://vaultwarden.de:4430
  1. Go through the setup

Install the self-signed certificate on your iOS/MacOS Device
15. Download the certificates from your Raspberry to your Computer. For example with Filezilla Bildschirmfoto 2021-10-10 um 19 05 55

  1. Transfer the bitwarden_cert.pem and the bitwarden_key.pem to your iOS Device with AirDrop or Email

Bildschirmfoto 2021-10-03 um 10 47 03

  1. Install both Certificates
    Mittel (136706907-fa377009-97e8-4e9e-a2a0-d9c1ee7c3524) Mittel (136706911-4022460e-f395-4195-8748-9c032f6deca6) Mittel (136706923-dbdba9f5-4977-46f7-b297-f35b28889915) Mittel (136706925-965cbe1f-49f8-4b95-85cf-d05189187405)

On MacOS you can import the Certificates via the Keychain App. Bildschirmfoto 2024-09-24 um 17 14 42

Both certificates should be trusted.

  1. If you have set multiple dns servers, it may not work. Set only the DNS server where the DNS forwarding set up above is enabled
    Mittel (136706225-649f3768-a76a-41b2-b93a-930328a75bfb)

  2. Start the Bitwarden App
    Mittel (136706404-53b463a1-59cb-4195-8711-c50eb2ca9cda)

  3. Enter at Server URL

https://vaultwarden.de:4430

Mittel (136706415-3034c4a2-c914-497c-bee1-ed64bf6963ac)

What to do if the certificate has expired?


- Delete the old bitwarden.crt file. (cd /home/pi/Docker/ssl/)
- Create a new one with:
openssl x509 -req -in bitwarden.csr -CA self-signed-ca-cert.crt -CAkey private-ca.key -CAcreateserial -out bitwarden.crt -days 365 -sha256 -extfile bitwarden.ext

- Enter a passphrase for the root certificate
- Use Filezilla to download the new bitwarden.crt to your computer
- Restart the Docker container for Vaultwarden
- Delete the old certificate from your devices (not the root certificate)
- Transfer the new bitwarden.crt to the devices and install it
- If you have renewed the certificate, it can happen that the Firefox Bitwarden add-on can no longer establish a connection to the server. The following must be done:
- Go to the Firefox settings and delete all cookies, website data and the cache under Privacy and security under Cookies and website data.
Bildschirmfoto 2024-11-09 um 15 43 16
- Go to Privacy and Security and click on Show certificates under Certificates. Then search for the entry Vaultwarden under Server and delete it. Now click on Add exceptions and enter https://vaultwarden.de:4430/ (or your correct address). Now download the certificate. If this fails, there is something wrong with your certificates.
Bildschirmfoto 2024-11-09 um 15 40 19
Bildschirmfoto 2024-11-09 um 15 41 08
Bildschirmfoto 2024-11-09 um 15 42 11
- It can't hurt to delete the Firefox addon from Bitwarden, restart Firefox and reinstall the addon.
- Restart Firefox

More information:

Backup your Vaultwarden Data:

About

Way to install Vaultwarden with HTTPS in local network with iOS integration

Topics

Resources

Stars

1 star

Watchers

1 watching

Forks

Releases

Packages

Contributors