Skip to content

Instantly share code, notes, and snippets.

@Neamar
Last active November 4, 2021 10:07
Show Gist options
  • Save Neamar/ca917e0dc5e387f4df59c188064f083d to your computer and use it in GitHub Desktop.
Save Neamar/ca917e0dc5e387f4df59c188064f083d to your computer and use it in GitHub Desktop.
Fix seafile invalid certificate in ssl folder

When restarting seafile, getting the following error:

nginx: [emerg] cannot load certificate "/shared/ssl/XXX.crt": BIO_new_file() failed (SSL: error:02001002:system library:fopen:No such file or directory:fopen('/shared/ssl/seafile.neamar.fr.crt','r'
) error:2006D080:BIO routines:BIO_new_file:no such file)  

where XXX is server name. According to seafile, this should have been solved automatically.

Restarting docker yields the same line in logs.

Solution seemed to be:

docker-compose down
docker pull seafileltd/seafile-mc:latest

mv /opt/seafile-data/ssl /opt/seafile-data/ssl.bkup
docker-compose up -d

At this point, everything is still failing. docker ps to get the id of the seafile container, then docker exec -it <dockerid> bash to enter the container.

cp /etc/nginx/sites-enabled/seafile.nginx.conf /tmp

Then edit /etc/nginx/sites-enabled/seafile.nginx.conf and remove the section related to SSL, to allow nginx to serve the well-known file. nginx -s reload, should have no error and an HTTP server available (with errors, but still, listening).

cd /scripts/
./ssl.sh /shared/ssl/ domain.com # where domain.com is your seafile domain
mv /tmp/seafile.nginx.conf /etc/nginx/sites-enabled/seafile.nginx.conf

nginx -s reload now simply displays a warning.

Exit docker, and confirm that /opt/seafile-data/ssl was created with keys and crt files. docker-compose down and docker-compose up -d to ensure everything is clean.

If, for some reason, your nginx config only includes the 80 port (e.g. you forgot to restore the nginx file) you can adapt this template https://github.com/haiwen/seafile-docker/blob/master/image/seafile/templates/seafile.nginx.conf.template

Links:

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