Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add TLS SNI support #108

Closed
wants to merge 11 commits into from
Closed

Add TLS SNI support #108

wants to merge 11 commits into from

Conversation

FGasper
Copy link

@FGasper FGasper commented Mar 23, 2019

This provides an easy way for server administrators to implement TLS SNI support in Pure-FTPd.

@jedisct1
Copy link
Owner

This doesn't compile and ever after some fixes, it didn't seem to work (tried on OpenBSD and MacOS as a server, lftp as client).

@jedisct1 jedisct1 closed this Mar 24, 2019
@FGasper
Copy link
Author

FGasper commented Mar 25, 2019

@jedisct1 Yeah, I didn’t intend this branch as-is for a merge per se; I was more asking for feedback on the approach.

My own testing was limited to openssl s_client; if you’re ok with this approach in principle, I’ll spend some more time with it.

Curious that it didn’t compile; I used MacOS as server myself.

@FGasper
Copy link
Author

FGasper commented Mar 25, 2019

So, just to be clear: if I get this branch working, compiling, testing, etc., will you accept it?

@jedisct1
Copy link
Owner

You need to test with other features compiled in (--with-everything) :)

Anyway, SNI support is implemented and documented already.

@FGasper
Copy link
Author

FGasper commented Mar 25, 2019

Ah, ok, now I see your recently-landed implementation. (Thank you!)

What is the benefit of having a separate daemon to invoke the command versus calling it from tls.c?

@jedisct1
Copy link
Owner

Better isolation, especially in a pre-authentication context.

The certd script and the FTP servers can run with different capabilities (which is already the case).

No need to fork a process every time, pure-certd can be replaced with anything that listens to the local UNIX socket.

And it's similar to the existing mechanism for external authentication, which is what you initially suggested.

@FGasper
Copy link
Author

FGasper commented Mar 25, 2019

Thanks!

@unique1984
Copy link

unique1984 commented Aug 19, 2022

Full installation documentation (Turkish)

Pure-Ftpd-Mysql with SNI Installation


pure-ftpd with SNI support (working & tested implementation) using Let's Encrypt (certbot)

Geather files (Debian)

apt source pure-ftpd-mysql
cd pure-ftpd-1.0.49

Step 1 Configure
nano debian/rules # append sbin binary pure-certd
image

./configure --with-mysql --with-tls --with-everything

Step 2 build package
dpkg-buildpackage -uc -us

Step 3 Install package that includes pure-certd
apt install -f ../pure-ftpd-mysql_1.0.49-4.1_amd64.deb

Step 4 Create TLS SNI parser shell script
nano /bin/pure-cert-check.sh

#! /usr/bin/sh

#echo "$(env)" > /root/sni_log
echo 'action:strict'
echo 'cert_file:/etc/letsencrypt/live/'${CERTD_SNI_NAME}'/fullchain.pem'
echo 'key_file:/etc/letsencrypt/live/'${CERTD_SNI_NAME}'/privkey.pem'
echo 'end'

Step 5 Start pure-certd daemon
pure-certd --run /bin/pure-cert-check.sh --socket /var/run/ftpd-certs.sock --pidfile /var/run/pure-certd.pid -B

Step 6 Append a line in to /usr/sbin/pure-ftpd-wrapper

                        'NoTruncate' => ['-0'],
+++                        'ExtCert' => [ '-3 %s', \&parse_string],
                        'PassivePortRange' => ['-p %d:%d', \&parse_number_2],

Step 7 ExtCert create (pure-ftpd.conf won't work...)

echo "/var/run/ftpd-certs.sock" > /etc/pure-ftpd/conf/ExtCert

Step 8

systemctl restart pure-ftpd-mysql.service

You should see something like;

Aug 19 23:42:20 testing systemd[1]: Stopping pure-ftpd-mysql.service...
Aug 19 23:42:20 testing pure-ftpd-mysql[207068]: Stopping ftp server: pure-ftpd.
Aug 19 23:42:20 testing systemd[1]: pure-ftpd-mysql.service: Succeeded.
Aug 19 23:42:20 testing systemd[1]: Stopped pure-ftpd-mysql.service.
Aug 19 23:42:20 testing systemd[1]: Starting pure-ftpd-mysql.service...
Aug 19 23:42:20 testing pure-ftpd-mysql[207077]: Starting ftp server:
Aug 19 23:42:20 testing pure-ftpd-mysql[207084]: Running: /usr/sbin/pure-ftpd-mysql -l mysql:/etc/pure-ftpd/db/mysql.conf -l pam -u 1000 -p 35000:50000 -E -A -Y 1 -O clf:/var/log/pure-ftpd/transfer.log **-3 /var/run/ftpd-certs.sock** -P 165.227.130.119 -J HIGH -j -B
Aug 19 23:42:20 testing systemd[1]: Started pure-ftpd-mysql.service.

in the syslog.

Step 8 Use it!

Cert 1

image

Cert 2

image

Have nice day...

P.S when you search all over the web (pure-ftpd sni support) this is the 1st page index of the google that is why i put this in here. I couldn't find any other step by step document then i experimented a way, succeeded to do this and i'm sharing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants