Thursday, September 22, 2016

Configure Prosody 0.9 for ChatSecure iOS push notifications

ChatSecure iOS now supports push notifications (XEP- 0357). Some limitations include limited to single client use and dependency on ChatSecure Push Server. However, this is good step forward and I welcome it. 

Good Read: https://github.com/ChatSecure/ChatSecure-Push-Server/tree/master/docs/v3

Included below is a brief guide to set up SSL which is a requirement for being able to send push notifications. Self signed certificates did not work for me. Please read reference for more info.

Make directory for non core modules:

# cd /etc/prosody/
# mkdir noncoremodules
# chown root:prosody noncoremodules/

Download mod_cloud_notify:

# cd /etc/prosody/noncoremodules/
# wget https://hg.prosody.im/prosody-modules/raw-file/tip/mod_cloud_notify/mod_cloud_notify.lua

(Alternate method in References)

Edit prosody config file:
Global Section

# cd /etc/prosody
# nano prosody.cfg.lua
...
modules_enabled = {   
        -- Non core plugins
                "cloud_notify"; -- Push Notifications
};

...
...
plugin_paths = { "/etc/prosody/noncoremodules/" } -- Path to non-core plugins 
...

(Note the module name is written as cloud_notify not mod_cloud_notify)

SSL using StartSSL:

Start the 'Validation Wizard' and validate your VirtualHost/Domain through email. We will use 'example.com' as the VirtualHost.

Start the 'Certification Wizard' for example.com
 

Generate CSR using prosodyctl on server
 

# prosodyctl cert request example.com 
# cd /var/lib/prosody
# cat example.com.req

 

Copy to CSR Box and run. Download Certificates zip file.

Extract OtherServer.zip 

1_Intermediate.crt 
2_example.com.crt 
root.crt


$ cat 1_Intermediate.crt >> 2_example.com.crt
$ scp 2_example.com.crt root@example.com:/var/lib/prosody/


(Intermediate certificate needs to be appended main certificate. Since I downloaded on my personal laptop I needed to scp the file to the server. This is not needed if the files are downloaded directly to server)

# chown prosody:prosody 2_example.com.crt
# chmod 600 2_example.com.crt 

 

Edit prosody config file: 
VirtualHost Section


# nano /etc/prosody/prosody.cfg.lua
...
VirtualHost "example.com"
        enabled = true
        ssl = {
                key = "/var/lib/prosody/example.com.key";
                certificate = "/var/lib/prosody/2_example.com.crt";
        }
...
 

Restart Prosody
 
# sudo -u prosody prosodyctl start

References:

https://prosody.im/doc/installing_modules#prosody-modules
https://prosody.im/doc/certificates
https://github.com/ChatSecure/ChatSecure-iOS/issues/557



No comments:

Post a Comment