Using and Abusing SSL Securty OR It must be secure, its so bloody hard to use (With apologies to Eric A. Young and the OpenSSL developers) Patrick Powell Thu Jul 18 10:20:58 PDT 2002 Executive Summary SSL Encryption and authentication is supported using the OpenSSL library. The following changes have been made to LPRng: lprng_certs - a certificate creation/management tool lpd.perms - AUTHFROM set to the 'subject' value of sender CERT AUTHCA set to the 'issuer' value of sender CERT and the hierarchy of 'issuer' values of CERT signers. ${HOME}/.lpr/client.crt, ${HOME}/.lpr/client.pwd - user or client certificate locations /etc/lpd/ssl.ca, /etc/lpd/ssl.server - locations of certificates and server certificates Introduction Why add SSL security to LPRng? a) It's there. b) Everybody and their dog is using it. c) It is needed to support IPP So I got hold of the SSL and TLS book by Eric Rescorla (he may regret this shameless plug, but be it on his head), and started reading it. After two weeks and a VERY large bottle of 'Super Strong No Doze Wakeup Pills' I figured out what needed to be done: a) Set up some certs (i.e. - X509 Authentication Certificates). b) Get some code from some other places and the examples. c) Read the code, figure out what it was doing, and then reverse engineer the SSL stuff. d) File off serial numbers, recode, etc., where necessary to 1) avoid the GNU license curse 2) make it LPRng specific My references were: Mod_ssl from the Apache project. http://www.apache.org Follow links to Mod_SSL OR get apache2 which has mod_ssl in it. Stole the organization for certs, as well as looking at how the Makefile created and installed the various certificates. fetchmail ftp://ftp.ccil.org/pub/esr/fetchmail http://www.tuxedo.org/~esr/fetchmail Ummm... this was happenstance, I use fetchmail and it has the SSL authentication in it. curl http://download.sourceforge.net/curl/ Again, I use curl and it has SSL. The articles by Eric Rescola: An Introduction to OpenSSL Programming http://www.rtfm.com/openssl-examples/ wserver, wclient, sclient And the book: SSL and TLS - Desiging and Building Secure Systems And, of course, the OpenSSL code, the examples in the code, the utilities, etc. etc. etc. About 260,000 lines of etc. Sigh... WHAT I DID a) Started with the Eric Rescola articles, and the examples for wserver, wclient. b) Added various things to handle getting authentication. - printing the Subject and Issuer information - adding directory information for Certificate locations c) Created new certificates using what I thought would work... d) Read 260,000 lines of OpenSSL code and heartily cursed the OpenSSL developers, the OpenSSL coders, and just about anybody who is associated with the project for NOT putting in some trace statements OR better error message reporting. But that is over new, and I have recalled the guys with the baseball bats. e) Documented this so that other people can figure out what I did. HERE IS WHAT YOU NEED TO KNOW The idea behind SSL is that you create some files (Certificates) that have various private/public key information in them. A checksum is calculated over the information, and then the checksum is 'encrypted' using a private key of some 'signer'. This is attached to the certficate file... and the whole thing is encoded in the most obnoxious manner... ANS1 to be exact. This is then EXPANDED into a text format called PEM, and forms the 'certificate file'. <aside> Ignore the SSL experts who are frothing over this cavalier description of the details. Details, smetails. You listen to them, you be on the No Doze, big time, pretty quick. Boring stuff, the SSL details</aside> Now lets see what we do to validate that a certificate is correct or from the 'Subject' who is identified in the Certificate. We get the X509 certificate for the 'signer' (or 'Issuer' in X509 jargon). Since the public key of the signer is including in the 'signer' certificate, we can use this to check that the information in the suspect certificate is valid by using it to decrypt the checksum information encoded with the private key. If this matches, we have validated the certificate. (Well, not quite. There are a couple more gotchas.) Now we must validate the 'signers' cerificate, which was in turn signed by another signer, and so we go up the food chain, I mean 'authentication chain', until we reach Nirvana: a certificate which is signed by itself (i.e. - root certificate) or more exactly, a certificate where the 'subject' or the person identified by the CERT and the 'issuer' or the person who signed the CERT are the same. Now lets see how we use this for printing. Each user and/or print spooler is given a certificate with a corresponding set of private and secret keys. When a client sends a request to the lpd server, he signs it using his private key; the lpd spooler gets the request, and then decodes/checks it using the public key in the users certificate. The SSL protocol provides a way to: a) set up an encrypted connection (not our problem) b) exchange certificate information (Hmm... need to tell OpenSSL what certs to exchange) c) validate the certificates (strictly speaking, this X509 stuff, but what the hey...) and hence, authenticate the end users. (Need to tell OpenSSL where the certs are). d) set up and perform encrypted data exchange. (not our problem). So all we really need to do is set up the CERTIFICATES, tell the OpenSSL library where they are, and it should do the work for us. (Ho ho ho... it sounds so simple...) There are two components to a certificate: a) the certificate file (name.crt file) itself b) the private key corresponding to the public key in the certificate file (name.key file). Now clearly if the private key was obtained by somebody then they could impersonate a user. So there are two possibilities: a) make the private key file readable only by the people that need it (more on this later). b) encrypt the private key and then when you need to use it to sign something, provide a decryption password/key. So, we have 3 components: the certificate (name.crt), the encrypted private key (name.key, but encrypted) and a password that we use to decrypt the private key. But since we do not need to keep the private key hidden away, we can put the private key and certificate in the same file: -----BEGIN RSA PRIVATE KEY----- Proc-Type: 4,ENCRYPTED DEK-Info: DES-EDE3-CBC,3EAD3ED0FA436761 Vi5K0olpFfe2ltDpY/7gPM4iW74gYqtO1yEFm1DOhp7Kd8hB5Is6TVuVX78zkTaP ... j6Z5TX61x4YCHKleFa9nXFC5god/MCYzIHKKep0f4TKWCZcJLR5AyQ== -----END RSA PRIVATE KEY----- -----BEGIN CERTIFICATE----- MIIDGzCCAoSgAwIBAgIBADANBgkqhkiG9w0BAQQFADCBkzELMAkGA1UEBhMCVVMx ... 3VapletoUPtYPvUAAgAg4w28pKWvlVW3tU/CsoHDEw== -----END CERTIFICATE----- Which is the convention we adopted for LPRng. Now lets deal with the problem of certificates. There are FOUR types of certificates that we need: CERTS/files root (/etc/lpd/ssl.ca/ca.crt) - signer1 (/etc/lpd/ssl.ca/signer1.crt - signed by ca) - print spoolers (/etc/lpd/ssl.server/h121.crt - signed by signer1 ) - users (${HOME}/.lpd/user1.crt - signed by signer1 ) - signer2 (/etc/lpd/ssl.ca/signer2.crt - signed by ca) - print spoolers (/etc/lpd/ssl.server/h121.crt - signed by signer2) - users (${HOME}/.lpd/user2.crt - signed by signer2) The ROOT cert signs the signer certs, which in turn can sign print spooler certs and user certs. If you feel lucky, you can also use the root cert to sign print spoolers or user certs. Now, what happens if and when somebody gets hold of the private key for the root cert or a signing cert? If it is for the root cert, you are doomed. Reissue all the CERTS. Start from square 0. If it is a signing cert, then you can REVOKE it. How do you do this? You put it into a 'revocation' directory, and then tell OpenSSL to do its magic and update the CERT information so that it is revoked. (More on this later). Finally, how does the certificate information get transferred? This is a little complicated, and there are a zillion ways to do this. I have opted to implement and use a very simple method based on the Apached mod_perl SSL setup. a) A directory (/etc/lpd/ssl.ca/) containing all of the signing certificates, including the root certificate (ca.crt). These will be used by both servers and clients. Note: due to the OpenSSL implementation, it may be necessary to copy files to this directory. OpenSSL also supports putting all of the certificates in a single file. The certificates should be put in root to leaf order, i.e. - a breadth first walk of the certificate tree. For individual signing/certificate files: printcap/configure option: ssl_ca_path=DIR default=/etc/lpd/ssl.ca/ssl.ca For single signing/certificate files: printcap/configure option: ssl_ca_file=FILE default= NONE configure: --with-ssl_ca_path=DIR default ${sysconfdir}/lpd/ssl.crt/ --with-ssl_ca_file=FILE default - none Note: See the SSL_CTX_load_verify_locations( SSL_CTX *ctx, const char *CAfile, const char *CApath); documentation for the details. b) The LPRng lpd server certifcate file and the password for using the certificate: A file (/etc/lpd/server.crt/server.crt) containing the cert that is used by the server. It should also contain the private key for the server. printcap/configure option: ssl_server_cert=FILE default ${sysconfdir}/lpd/server.crt/server.crt configure: --with-ssl_server_cert=PATH default ${sysconfdir}/lpd/server.crt/server.crt Note: See SSL_CTX_use_certificate_chain_file( SSL_CTX *ctx, const char *file); SSL_use_PrivateKey_file(SSL *ssl, char *file, int type); documentation for details. Note that this file can contain multiple certs, but these must be sorted in top (root CA) to bottom (server) order. i.e. - private_key, server cert (additional certs specified by ssl_ca_path or ssl_ca_file) OR root CA cert, signer1 cert, ..., server cert Note: the private key can be in any position. The password file file contains the password for the private key in the server cert file. This file should to be 600, owned by the LPD server user. printcap/configure option: ssl_server_passwd=FILE default ${sysconfdir}/lpd/server.crt/server.crt configure: --with-ssl_server_passwd=PATH Note: See the SSL_CTX_set_default_passwd_cb for details. The password is read from the file. d) For user authentication to the server, users will need to specify a certificate and password. This can be by using values in default files or ${HOME}/.lpr/ssl.ca/ - signing/root certificates (if not present, then ${sysconfdir}/lpd/ssl.ca/ is used) Environment variable: LPR_CA_PATH ${HOME}/.lpr/client.crt - client cert and key Environment variable: LPR_SSL_CERT ${HOME}/.lpr/client.pwd - file containing client password Environment variable: LPR_SSL_PASSWORD CERTIFICATE FIELDS: There are several fields that need to be set in a certificate/ C = country [US] ST = state [California] L = city [San Diego] OU = Organization Unit [OU=Certificate Authority for root cert] [OU=Server for server cert] [OU=User for user cert] CN = Common Name [CN=Orgname for root cert] [CN=ServerID (h110.astart) for server cert] [CN=papowell for user cert] Email = email address [Email=hostmaster@astart.com for root cert] [Email=hostmaster@h110.astart for server cert] [Email=papowell@astart.com for user cert] You can set default values for these fields. SETTING UP CERTIFICATE AUTHORITY There are several types of certificate files: - CA root (self signed) - signing certs (signed by CA or by signing cert) - server certs (used by lpd server AND by lpd server when forwarding to a remote queue) - user certs (used to identify users programs) The certificates are arranged as follows: 1. signing certs are in a directory (or a single file) default: /etc/lpd/ssl.ca/* 2. server certs are in a directory default: /etc/lpd/ssl.server/* 3. user certificates are kept in a subdirectory of the user home directory, say: ${HOME}/.lpr/client.crt - cert ${HOME}/.lpr/client.pwd - password to use cert private key for authentication 4. certificates are created in a working directory and are then copied (if necessary) to the correct directory. default: /etc/lpd/ssl.certs PRINTCAP INFORMATION: the following entries are added to the printcap or lpd.conf file: lp: :auth=ssl # ssl authentication :ssl_id=lp # id value :ssl_ca_file=/etc/lpd/ssl.ca/ca.crt # certs for signing :ssl_crl_file=/etc/lpd/ssl.crl/ssl.crl # revocation certs :ssl_server_cert=/etc/lpd/ssl.server/server.crt # server cert :ssl_server_password_file=/etc/lpd/ssl.server/server.pwd # password CREATING CERTS The lprng_certs script provides a way to create ROOT certs, signer certs, server (lpd) certs, and user certs. You may need to copy the certificate files to the appropriate locations. usage: lprng_certs option init - make directory structure newca - make new root CA and defaults defaults - set new default values encrypt keyfile - set or change password on private key file gen - generate user, server, or signing cert verify cert* - verify certs certs can be path or user-XX.csr values STEP 1: CREATE DIRECTORY STRUCTURE Use: lprng_certs [--TEMP=/dir] init - creates directories for lpd server TEMP=/dir sets the directory; byt default, TEMP=/etc/lpd ${TEMP}/ssl.ca/ - ca root and/or signer certs default location for creation ${TEMP}/ssl.server/ - server cert (usually server.crt and server.pwd files) ${TEMP}/ssl.certs/ - server and/or user certs default location for creation You use this to set up the directories for certificates on a non-master system. STEP 2: CREATE CA ROOT CERT AND SET CERTIFICATE DEFAULTS Use: lprng [--TEMP=/dir] newca You use this when you want to set up a totally new CA on a master system. Example of use: #> lprng_certs newca lprng_certs -- LPRng SSL Certificate Management Copyright (c) 2002 Patrick Powell Based on CCA by Ralf S. Engelschall (Copyright (c) 1998-2001 Ralf S. Engelschall, All Rights Reserved.) WARNING: /etc/lpd/ssl.ca/ca.crt already exists! Do you want to overwrite it? [N/y] Y INITIALIZATION - SET DEFAULTS There are several fields that need to be set in a certificate/ C = country [US] ST = state [California] L = city [San Diego] OU = Organization Unit [OU=Certificate Authority for root cert] [OU=Server for server cert] [OU=User for user cert] CN = Common Name [CN=Orgname for root cert] [CN=ServerID (h110.astart) for server cert] [CN=papowell for user cert] Email = email address [Email=hostmaster@astart.com for root cert] [Email=hostmaster@h110.astart for server cert] [Email=papowell@astart.com for user cert] You can set default values for these fields. 110: {90} % lprng_certs --TEMP=/tmp newca lprng_certs -- LPRng SSL Certificate Management Copyright (c) 2002 Patrick Powell Based on CCA by Ralf S. Engelschall (Copyright (c) 1998-2001 Ralf S. Engelschall, All Rights Reserved.) INITIALIZATION - SET DEFAULTS in /tmp/ssl.ca/ca.defaults *** you can change the defaults as shown *** 1. Country Name (2 letter code, C) [default 'XY'] US 2. State or Province Name (full name, ST) [default 'Snake Desert'] California 3. Locality Name (eg, city, L) [default 'Snake Town'] San Diego 4. Organization Name (eg, company, O) [default 'Snake Oil, Ltd'] Astart Technologies 5. Organizational Unit Name for CA (eg, section, OU) [default 'CA'] 6. Organizational Unit Name for Signer (eg, section, OU) [default 'Signer'] 7. Organizational Unit Name for Server (eg, section, OU) [default 'Server'] 8. Organizational Unit Name for User (eg, section, OU) [default 'User'] 9. Common Name for CA (eg, CA name, CN) [default 'Snake Oil CA'] Astart CA 10. Common Name for Signer (eg, signer name, CN) [default 'Signer Name'] 11. Common Name for Server (eg, server name, CN) [default 'PrintServer Name'] 12. Common Name for User (eg, user name, CN) [default 'John Q. User'] 13. Email Address (eg, name@FQDN, Email) [default 'name@snakeoil.dom'] name@astart.com 14. CA Certificate Validity in days [default '365'] 15. Signer Certificate Validity in days [default '365'] 16. Server Certificate Validity in days [default '365'] 17. User Certificate Validity in days [default '365'] 18. Signer Certificate Path (blank indicates CA signs) [default ''] 19. Signer Private Key File (blank indicates key in cert file) [default ''] 20. Created Certificates Directory (blank indicates default /tmp/ssl.certs) [default ''] 21. Revoked Certificates File (blank indicates default /tmp/certs.crl) [default ''] **** this shows what the new default value will be ***** C_val US ST_val California L_val San Diego O_val Astart Technologies OU_ca_val CA OU_signer_val Signer OU_server_val Server OU_user_val User CN_ca_val Astart CA CN_signer_val Signer Name CN_server_val PrintServer Name CN_user_val John Q. User Email_val name@astart.com Validity_ca_val 365 Validity_signer_val 365 Validity_server_val 365 Validity_user_val 365 Signer_cert_path Signer_key_path Cert_dir Revoke_file ... ______________________________________________________________________ STEP 1: Generating RSA private key for CA (1024 bit) 49279 semi-random bytes loaded Generating RSA private key, 1024 bit long modulus .........................................++++++ .................++++++ e is 65537 (0x10001) ______________________________________________________________________ STEP 2: Generating X.509 certificate signing request for CA You are about to be asked to enter information that will be incorporated into your certificate request. What you are about to enter is what is called a Distinguished Name or a DN. There are quite a few fields but you can leave some blank For some fields there will be a default value, If you enter '.', the field will be left blank. *** change any of the field names *** ----- 1. Country Name (2 letter code, C) [US]: 2. State or Province Name (full name, ST) [California]: 3. Locality Name (eg, city, L) [San Diego]: 4. Organization Name (eg, company, 0) [Astart Technologies]: 5. Organizational Unit Name (eg, section, OU) [CA]: 6. Common Name (eg, ca name, CN) [Astart CA]: 7. Email Address (eg, name@FQDN, Email) [name@astart.com]:root@astart.com ______________________________________________________________________ STEP 3: Generating X.509 certificate for CA signed by itself Signature ok subject=/C=US/ST=California/L=San Diego/O=Astart Technologies/OU=CA/CN=Astart CA/emailAddress=root@astart.com Getting Private key ______________________________________________________________________ RESULT: /tmp/ssl.ca/ca.crt: /C=US/ST=California/L=San Diego/O=Astart Technologies/OU=CA/CN=Astart CA/emailAddress=root@astart.com error 18 at 0 depth lookup:self signed certificate OK ______________________________________________________________________ STEP 4. Enrypting RSA private key /tmp/ssl.ca/ca.key with a pass phrase for security The contents of the certificate key file (the generated private key) should be echo kept secret, especially so if it is used to sign Certificates or for User authentication. SSL experts strongly recommend you to encrypt the key file with a Triple-DES cipher and a Pass Phrase. When using LPRng, you provide the password via a file specified by the LPR_SSL_PASSWORD environent variable, or in the /home/papowell/.lpr/client.pwd file. The LPD server uses the ssl_server_password_file option to specify the location of a file containing the password. Encrypt the private key now? [Y/n]: writing RSA key Enter PEM pass phrase: Verifying - Enter PEM pass phrase: Fine, you're using an encrypted private key to sign CERTS. ______________________________________________________________________ STEP 5: Combine CERT and KEY file Generate single CERT and KEY file? [N/y] Indexing /tmp/ssl.ca ca.crt ... cbd552ae.0 Use the following commands to examine the CERT and KEY files: openssl x509 -text -in /tmp/ssl.ca/ca.crt openssl rsa -text -in /tmp/ssl.ca/ca.key STEP 3: CREATE SERVER CERTS AND INSTALL ON SERVERS Creates a certificate with the appropriate entries for use as a server (lpd) certificate. Example: #> lprng_certs gen lprng_certs -- LPRng SSL Certificate Management Copyright (c) 2002 Patrick Powell Based on CCA by Ralf S. Engelschall (Copyright (c) 1998-2001 Ralf S. Engelschall, All Rights Reserved.) CERTIFICATE GENERATION What type of certificate? User/Server/Signing Authority/Help? [u/s/a/H] s Create in '/etc/lpd/ssl.certs' [return for yes, or specify directory] y CERT name 'server-01'? [return for yes, or specify name] h110 CERT name 'h110'? [return for yes, or specify name] Creating h110 in /etc/lpd/ssl.certs Sign with Certificate '/etc/lpd/ssl.ca/ca.crt' [return for yes, or specify cert file] Private key in /etc/lpd/ssl.ca/ca.crt Generating user Certificate [h110] ______________________________________________________________________ STEP 1: Generating RSA private key for user (1024 bit) ______________________________________________________________________ STEP 2: Generating X.509 certificate signing request for user User Certificate Validity in days [default 365] ______________________________________________________________________ STEP 3: Generating X.509 certificate signed by own CA ______________________________________________________________________ RESULT: /etc/lpd/ssl.certs/h110.crt: OK ______________________________________________________________________ STEP 4. Enrypting RSA private key with a pass phrase for security The contents of the certificate key file (the generated private key) should be echo kept secret, especially so if it is used to sign Certificates or for User authentication. SSL experts strongly recommend you to encrypt the key file with a Triple-DES cipher and a Pass Phrase. When using LPRng, you provide the password via a file or file descriptor specified by an environent variable, i.e. - SSL_PASSWORD_FILE or SSL_PASSWORD_FD, or in the ${HOME}/.ssl_password file. The LPD server uses the ssl_server_password_file option to specify the location of a file containing the password. See the LPRng Refernce Manual for details, or the printcap(5) man page. key file is /etc/lpd/ssl.certs/h110.key Encrypt the private key now? [Y/n]: y Fine, you're using an encrypted private key to sign CERTS. ______________________________________________________________________ STEP 5: Combine CERT and KEY file Generate single CERT and KEY file? [Y/n] y Use the following commands to examine the CERT and KEY files: openssl x509 -text -in /etc/lpd/ssl.certs/h110.crt openssl rsa -text -in /etc/lpd/ssl.certs/h110.crt ---------- You must now copy the h110.crt certificate to the lpd server certificate file location: cp /etc/lpd/ssl.certs/h110.crt /etc/lpd/server.cert/server.crt echo 'password' >/etc/lpd/server.crt/server.pwd chown lpd /etc/lpd/server.crt/server.pwd chmod 700 /etc/lpd/server.crt/server.pwd (Note: lpd is the user that the LPD server will run as. This value is set by the configuration in the lpd.conf file.) STEP 5: CREATE AND INSTALL USER CERTS Creates a certificate with the appropriate entries for use as a server (lpd) certificate. Example: #> lprng_certs gen lprng_certs -- LPRng SSL Certificate Management Copyright (c) 2002 Patrick Powell Based on CCA by Ralf S. Engelschall (Copyright (c) 1998-2001 Ralf S. Engelschall, All Rights Reserved.) CERTIFICATE GENERATION What type of certificate? User/Server/Signing Authority/Help? [u/s/a/H] u Create in '/etc/lpd/ssl.certs' [return for yes, or specify directory] y CERT name 'user-01'? [return for yes, or specify name] papowell CERT name 'papowell'? [return for yes, or specify name] Creating h110 in /etc/lpd/ssl.certs Sign with Certificate '/etc/lpd/ssl.ca/ca.crt' [return for yes, or specify cert file] Private key in /etc/lpd/ssl.ca/ca.crt ... Use the following commands to examine the CERT and KEY files: openssl x509 -text -in /etc/lpd/ssl.certs/papowell.crt openssl rsa -text -in /etc/lpd/ssl.certs/papowell.crt ---------- You must now copy the papowell.crt certificate to the user .lpd directory and then set the password. cp /etc/lpd/ssl.certs/papowell.crt ~papowell/.lpd/client.crt echo 'password' >~papowell/.lpd/client.pwd chown papowell ~papowell/.lpd/client.pwd chmod 700 ~papowell/.lpd/client.pwd CREATE A SIGNING CERT You will need to do this if you want to create a certificate that you can use to sign other certificates - i.e. - delegate signing authority. This is done by creating a signing certificate. The private key file for this certificate should be treated in the same was as for the root certificate - it should not be stored in the same file as the certificate, or if it is, the password for the key should be very long and resistant to a dictionary attack. I do not recommend storing the private key and certificate in the same file. lprng_certs -- LPRng SSL Certificate Management Copyright (c) 2002 Patrick Powell Based on CCA by Ralf S. Engelschall (Copyright (c) 1998-2001 Ralf S. Engelschall, All Rights Reserved.) CERTIFICATE GENERATION What type of certificate? User/Server/Signing Authority/Help? [u/s/a/H] a Create in '/etc/lpd/ssl.ca' [return for yes, or specify directory] CERT name 'signer-02'? [return for yes, or specify name] Creating signer-02 in /etc/lpd/ssl.ca Sign with Certificate '/etc/lpd/ssl.ca/ca.crt' [return for yes, or specify cert file] Private key in /etc/lpd/ssl.ca/ca.crt Generating signer Certificate [signer-02] ______________________________________________________________________ STEP 1: Generating RSA private key for signer (1024 bit) ______________________________________________________________________ STEP 2: Generating X.509 certificate signing request for signer User Certificate Validity in days [default 365] ______________________________________________________________________ STEP 3: Generating X.509 certificate signed by own CA ______________________________________________________________________ RESULT: /etc/lpd/ssl.ca/signer-02.crt: OK ______________________________________________________________________ STEP 4. Enrypting RSA private key with a pass phrase for security The contents of the certificate key file (the generated private key) should be echo kept secret, especially so if it is used to sign Certificates or for User authentication. SSL experts strongly recommend you to encrypt the key file with a Triple-DES cipher and a Pass Phrase. When using LPRng, you provide the password via a file or file descriptor specified by an environent variable, i.e. - SSL_PASSWORD_FILE or SSL_PASSWORD_FD, or in the ${HOME}/.ssl_password file. The LPD server uses the ssl_server_password_file option to specify the location of a file containing the password. See the LPRng Refernce Manual for details, or the printcap(5) man page. key file is /etc/lpd/ssl.ca/signer-02.key Encrypt the private key now? [Y/n]: Fine, you're using an encrypted private key to sign CERTS. ______________________________________________________________________ STEP 5: Combine CERT and KEY file Generate single CERT and KEY file? [Y/n] Use the following commands to examine the CERT and KEY files: openssl x509 -text -in /etc/lpd/ssl.ca/signer-02.crt openssl rsa -text -in /etc/lpd/ssl.ca/signer-02.crt - creates a certificate with the appropriate entries for use as a signing, server (lpd), or client (user) certificate. TESTING SSL AUTHENTICATION Set up a printcap entry: ssl: :auth=ssl :ssl_id=lp :ssl_ca_file=/etc/lpd/ssl.ca/ca.crt :ssl_crl_file=/etc/lpd/ssl.crl/ssl.crl :ssl_server_cert=/etc/lpd/ssl.server/server.crt :ssl_server_password_file=/etc/lpd/ssl.server/server.pwd :sd=/var/spool/lpd/%P :lp=/dev/null # for debugging only! :db=2 Create the spool queue by using: checkpc -f Use the lprng_ssl script described above to create the ssl certs and install them as required. Now restart LPD in debug mode, so you can kill it: lpd -F -D1 Use the 'lpq' command to connect to the server: lpq -Pssl -D1 |&tee /tmp/log If this fails, examine the /var/spool/lpd/ssl/log file for reasons that the server failed. Examine the /tmp/log file for reasons that the client failed. CERTIFICATE REVOCATION AND PERMSSIONS CHECKING The current implementation does not support or provide support for the X509 Certificate Revocation List or files. Instead, we use the lpd.perms facilities and reject user and/or signers based on the information in their 'subject' or 'issuer' information. The AUTHFROM and AUTHCA contain the subject and issuer information for the user certificate received by the LPD server. Actually, the AUTHCA information contains the hierarchy of certificate signers, so you can reject a request based on the presence or abscence of a certificate signer. For example: h110: {230} % openssl x509 -issuer -subject -noout -in ${HOME}/.lpr/client.crt issuer= /C=US/ST=California/L=San Diego/O=Astart/\ OU=CertificateAuthority/CN=AstartCA/Email=ca@astart.com subject= /C=US/ST=California/L=San Diego/O=Astart/\ OU=Server/CN=papowell/Email=papowell@astart.com You can now use: # /etc/lpd.perms REJECT NOT AUTHTYPE=ssl REJECT NOT AUTHCA=*/CN=AstartCA/* REJECT AUTHFROM=*/CN=papowell/* You can also put this in a file, say /etc/lpd/signers.auth */CN=AstartCA/* and, say /etc/lpd/reject.users */CN=papowell/* Now you can use: REJECT NOT AUTHCA=</etc/lpd/signers.auth REJECT AUTHFROM=</etc/lpd/reject.users