Setting up an mSign server: Difference between revisions
John Powers (talk | contribs) No edit summary |
John Powers (talk | contribs) No edit summary |
||
Line 9: | Line 9: | ||
1. Obtain the scriptel-msign-x.x.xx-all.deb package and license file from Scriptel | 1. Obtain the scriptel-msign-x.x.xx-all.deb package and license file from Scriptel | ||
2. Obtain a server with Ubuntu | 2. Obtain a server with Ubuntu 16.04 on it. | ||
3. Install PostgreSQL | 3. Install PostgreSQL |
Revision as of 13:43, 17 August 2017
This guide is for administrators in organizations who have purchased an mSign server license. Scriptel provides a public server for public use free of charge at msign.scriptel.com. However, this requires internet connectivity and is shared. Organizations may wish to use their own server behind their firewall. A 90-day trial license is available upon request.
mSign Sever is designed to run on an Ubuntu 16.04 server. It is written node.js, so technically it is possible to make it run on any platform that supports node. However, all of the scripts for installing are written for Ubuntu and that is all we are currently supporting.
mSign Server requires connection to a PostgreSQL database. This can live on the local machine or elsewhere. These instructions will assume it lives on the local system.
Set up the service:
1. Obtain the scriptel-msign-x.x.xx-all.deb package and license file from Scriptel
2. Obtain a server with Ubuntu 16.04 on it.
3. Install PostgreSQL
sudo apt-get update sudo apt-get install postgresql postgresql-contrib
4. Start command line PostgreSQL
sudo -u postgres psql
5. type, changing the password 'secret' to a reasonable password.
CREATE USER "scriptel-msign" WITH PASSWORD 'secret'; CREATE DATABASE "scriptel-msign" WITH OWNER 'scriptel-msign'; \q
6. Start the install of mSign server
sudo apt-get install -f ./scriptel-msign-*-all.deb
7. Take the default answers, except password. Make the password the same as in step 5.
8. Create the user
cd /usr/lib/scriptel-msign sudo -u scriptel-msign node msign-util.js --create-user=guy@email.com:guysPassword
9. Create an organization
sudo -u scriptel-msign node msign-util.js -o organization
10. Assign the user to the organization
sudo -u scriptel-msign node msign-util.js -a guy@email.com:organization
11. If the directory /usr/lib/scriptel-msign/licenses does not exist, create it.
sudo -u scriptel-msign mkdir licenses
12. License the server. This assumes that Scriptel has granted you a license. If not, this step will fail. This is the portal username and password, which may be different than one created earlier.
sudo -u scriptel-msign node msign-util.js --download-licenses guy@email.com:guysPassword
13. Start the service
sudo service scriptel-msign start
14. Make the service automatically start when the system is rebooted
sudo systemctl enable scriptel-msign.service
At this point, your mSign Desktop and mSign Mobile applications should be able to connect to the server on port 8443. For example, if your IP address were 54.291.191.59 you would put this into the applications as https://54.291.191.59:8443. You can try this using a browser for mSign Mobile as long as it will allow you to get to it as an unsafe site. Chrome will allow this, for example, but you will not be able to use the mSign mobile app for Android until there is a certificate.
Reassign the ports
This section is optional. mSign Server runs natively on ports 8080 and 8443. You might want to use the standard http and https ports 80 and 443. You have to do this if you use Letsencrypt for a certificate in the next section.
sudo apt-get install iptables-persistent sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080 sudo iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 443 -j REDIRECT --to-port 8443 sudo /etc/init.d/netfilter-persistent save
Install a certificate
To avoid security warnings you need to install a certificate. You can buy one and install it. Or you can self-certify, but if you do, you will have to set yourself up as a root authority on each mobile device you use. Or you can use Let's Encrypt, which is free, but requires that the server be public on the internet so that it can validate ownership of the domain.
These instructions are for Let's Encrypt:
1. Let's Encrypt requires that standard ports be used. So if you haven't already done so, reassign the ports as described in the previous section.
2. Give your server a DNS name with your DNS provider and wait for it to propogate. This can be a subdomain of one you already own.
3. Type the following, substituting your domain for domain.example.com:
sudo apt-get install software-properties-common sudo add-apt-repository ppa:certbot/certbot sudo apt-get install certbot sudo certbot certonly --webroot -w /usr/lib/scriptel-msign/www -d domain.example.com
4. Create a file with the following text, but replace domain.example.com with your domain. Call it something like renewcert.sh
#!/bin/bash #=============================================================================== # This script is responsible for automatically renewing a Let's Encrypt # certificate for Scriptel mSign on a regular interval. # # Copyright 2017 - Scriptel Corporation #=============================================================================== #Change these variables to match your environment if required. CP=/bin/cp CHOWN=/bin/chown CHMOD=/bin/chmod SERVICE=/usr/sbin/service LETS_ENCRYPT=/usr/bin/certbot CERT_DIR=/etc/letsencrypt/live/domain.example.com MSIGN_DIR=/usr/lib/scriptel-msign/ssl SERVICE_NAME=scriptel-msign USER_NAME=scriptel-msign #You shouldn't need to change anything below this line. #------------------------------------------------------------------------------- $LETS_ENCRYPT renew if [ $? -eq 0 ]; then $CP "$CERT_DIR/cert.pem" "$MSIGN_DIR/public.pem" $CP "$CERT_DIR/privkey.pem" "$MSIGN_DIR/private.pem" $CP "$CERT_DIR/chain.pem" "$MSIGN_DIR/intermediate.pem" $CHOWN $USER_NAME "$MSIGN_DIR/public.pem" "$MSIGN_DIR/private.pem" "$MSIGN_DIR/intermediate.pem" $CHMOD 600 "$MSIGN_DIR/public.pem" "$MSIGN_DIR/private.pem" "$MSIGN_DIR/intermediate.pem" $SERVICE $SERVICE_NAME restart echo "Successfully renewed certificate and restarted $SERVICE_NAME." echo `date` else echo "Failed to renew certificate." echo `date` fi
5. Execute the file.
chmod 755 renewcert.sh sudo ./renewcert.sh
6. The certificat from Let's encrypt is good for 90 days. Running the script will renew it if it is within 30 days of expireation. You can create a cron job to renew the certficate. The following will run the job at 3:43AM (computer time) on Mondays. This should be done during low usage as it will cause msign-server to restart. Change the paths and file names according to what you chose in step 4.
sudo crontab -e 43 3 * * 1 /home/ubuntu/renewcert.sh >>/home/ubuntu/renewcert.log