# Replace ssl certificate

**URL:** https://forum.syncthing.net/t/replace-ssl-certificate/8168
**Category:** Support
**Created:** [September 4, 2016, 10:16pm UTC](https://forum.syncthing.net/t/replace-ssl-certificate/8168 "2016-09-04T22:16:53Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![ambipur](https://forum.syncthing.net/letter_avatar_proxy/v4/letter/a/ec9cab/32.png) [@ambipur](https://forum.syncthing.net/u/ambipur)
#### Post date: [September 4, 2016, 10:16pm UTC](https://forum.syncthing.net/t/replace-ssl-certificate/8168/1 "2016-09-04T22:16:53Z")

</div>

I have replaced the self signed ssl certificates with not self signed ones, but syncthing somehow regenerates the original certificate when I restart the service. Has anybody an idea?

---

<div class="post-metadata">

### Author: ![Nutomic](https://forum.syncthing.net/user_avatar/forum.syncthing.net/nutomic/32/270_2.png) [@Nutomic](https://forum.syncthing.net/u/Nutomic)
#### Post date: [September 4, 2016, 11:07pm UTC](https://forum.syncthing.net/t/replace-ssl-certificate/8168/2 "2016-09-04T23:07:13Z")

</div>

What’s does Syncthing print in the logs when you start it?

---

<div class="post-metadata">

### Author: ![kluppy](https://forum.syncthing.net/user_avatar/forum.syncthing.net/kluppy/32/4197_2.png) [@kluppy](https://forum.syncthing.net/u/kluppy)
#### Post date: [September 5, 2016, 4:47am UTC](https://forum.syncthing.net/t/replace-ssl-certificate/8168/3 "2016-09-05T04:47:42Z")

</div>

Sounds like you may be using a script to start syncthing that uses a different home location than you expect.

---

<div class="post-metadata">

### Author: ![ambipur](https://forum.syncthing.net/letter_avatar_proxy/v4/letter/a/ec9cab/32.png) [@ambipur](https://forum.syncthing.net/u/ambipur)
#### Post date: [September 5, 2016, 5:26pm UTC](https://forum.syncthing.net/t/replace-ssl-certificate/8168/4 "2016-09-05T17:26:14Z")

</div>

I am using on Debian 8 the following init script located at /etc/init.d

```
#!/bin/sh

### BEGIN INIT INFO
# Provides: syncthing
# Required-Start: $local_fs $remote_fs
# Required-Stop: $local_fs $remote_fs
# Should-Start: $network
# Should-Stop: $network
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Multi-user daemonized version of syncthing.
# Description: Starts the syncthing daemon for all registered users.
### END INIT INFO

# Replace with users you want to run syncthing clients for
syncthing_USERS="root"
LOGFILE=/var/log/syslog
DAEMON=/usr/bin/syncthing

startd() {
  for stuser in $syncthing_USERS; do
    HOMEDIR=$(getent passwd $stuser | awk -F: '{print $6}')
    if [-f $config]; then
      echo "Starting syncthing for $stuser"
      start-stop-daemon -b -o -c $stuser -S -u $stuser -x $DAEMON
    else
      echo "Couldn't start syncthing for $stuser (no $config found)"
    fi
  done
}

stopd() {
  for stuser in $syncthing_USERS; do
    dbpid=$(pgrep -fu $stuser $DAEMON)
    if [! -z "$dbpid"]; then
      echo "Stopping syncthing for $stuser"
      start-stop-daemon -o -c $stuser -K -u $stuser -x $DAEMON
    fi
  done
}

status() {
  for stuser in $syncthing_USERS; do
    dbpid=$(pgrep -fu $stuser $DAEMON)
    if [-z "$dbpid"]; then
      echo "syncthing for USER $stuser: not running."
    else
      echo "syncthing for USER $stuser: running (pid $dbpid)"
    fi
  done
}

case "$1" in
  start) startd
    ;;
  stop) stopd
    ;;
  restart|reload|force-reload) stopd && startd
    ;;
  status) status
    ;;
  *) echo "Usage: /etc/init.d/syncthing {start|stop|reload|force-reload|restart|status}"
     exit 1
   ;;
esac

exit 0
```

---

<div class="post-metadata">

### Author: ![ambipur](https://forum.syncthing.net/letter_avatar_proxy/v4/letter/a/ec9cab/32.png) [@ambipur](https://forum.syncthing.net/u/ambipur)
#### Post date: [September 5, 2016, 5:34pm UTC](https://forum.syncthing.net/t/replace-ssl-certificate/8168/5 "2016-09-05T17:34:48Z")

</div>

According to the init script above, I suppose I should see in /var/log/syslog at least I have started or stopped syncthing, but grepping the syslog about sync, I get nothing. Can I configure syncthing log level somehow?

---

<div class="post-metadata">

### Author: ![canton7](https://forum.syncthing.net/user_avatar/forum.syncthing.net/canton7/32/9528_2.png) [@canton7](https://forum.syncthing.net/u/canton7)
#### Post date: [September 5, 2016, 6:39pm UTC](https://forum.syncthing.net/t/replace-ssl-certificate/8168/6 "2016-09-05T18:39:04Z")

</div>

My guess is that it’ll be putting the certs in `/root/.config/syncthing`

---

<div class="post-metadata">

### Author: ![calmh](https://forum.syncthing.net/user_avatar/forum.syncthing.net/calmh/32/15311_2.png) [@calmh](https://forum.syncthing.net/u/calmh)
#### Post date: [September 5, 2016, 6:51pm UTC](https://forum.syncthing.net/t/replace-ssl-certificate/8168/7 "2016-09-05T18:51:13Z")

</div>

That init script is really, _really_ bad. You should stop using it in favor of one of the alternatives we ship, and complain loudly to whomever gave it to you. It’s essentially blind luck that it manages to start Syncthing at all.

Why the actual fuck does `[-f $undefinedVariable]` evaluate to true? I’m attributing that to some POSIX compatibility damage, and the script above depends on it… Bash, correctly used, avoids that bug at least.

---

<div class="post-metadata">

### Author: ![xor-gate](https://forum.syncthing.net/user_avatar/forum.syncthing.net/xor-gate/32/2934_2.png) [@xor-gate](https://forum.syncthing.net/u/xor-gate)
#### Post date: [September 5, 2016, 7:22pm UTC](https://forum.syncthing.net/t/replace-ssl-certificate/8168/8 "2016-09-05T19:22:25Z")

</div>

Who uses nasty SYS-V init scripts when systemd is available should be punished 😛. \*BSD is the exception.

---

<div class="post-metadata">

### Author: ![system](https://forum-uploads.syncthingcdn.net/original/2X/0/0b50e0a202b22ae6a67190759e8c868805b8ed9f.png) [@system](https://forum.syncthing.net/u/system)
#### Post date: [October 5, 2016, 7:37pm UTC](https://forum.syncthing.net/t/replace-ssl-certificate/8168/9 "2016-10-05T19:37:17Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
