Create and install server certificate

This page describes how to create certificates for servers under Linux/MacOSX and Windows. An admin-customary technical adeptness is assumed.

General comments

  • The certificate usually attests to one (or more) DNS names of the server. It is theoretically possible to testify public IP addresses, but usually not useful. Wildcard certificates can only be issued in  technically justified individual cases (in german).
  • Key and certificate application should always be created on the named computer itself. This avoids, for example, that a workstation hard disk is taken out of service, which still contains keys (and certificate) for servers.
  • One certificate can testify to multiple DNS names. This is usually associated with more configuration effort when creating the request. It is possible for the subscriber service to add more names after the application has been submitted, and it is usually easier.
  • A certificate can be 'renewed' in the sense that a new certificate is issued for the same key pair. It is then not necessary to generate a new certificate application. (Please note: some appliances cannot import a new certificate to an existing key. In this case, you must submit a new application).
  • We currently recommend RSA/3072 bit for the key material. (The BSI recommends (in german) that certificates with 2048 bits be phased out by 2022, the end date for 3072 bits is currently seen beyond 2023. Elliptical curves were not supported by the DFN-PKI during the last test in early 2018. The use of longer keys, e.g. RSA/4096 bit is technically possible, but there may be compatibility problems with crypto smart cards).
  • After uploading the certificate application to the DFN-PKI you will receive a PDF. This must be submitted to the PKI participant service, e.g. by internal mail. If we do not already have one, the approval of the institute for the preparation of the certificate (form 19) must be submitted with the certificate.
  • In addition to the certificate, the rest of the certificate chain must be installed. (This certifies that T-Systems has authorised the DFN-PKI to issue certificates for us). How exactly this is done depends on the server software and/or operating system.

Creation of a certificate request under Linux/MacOS X with openssl

Creating a key

With the following command line a key key.pem can be generated. If the -aes256 is omitted, the key is not password-protected and must then be protected against misuse by other technical-organizational measures.

openssl genrsa [-aes256] -out key.pem 3072

Creating the certificate application

The certificate application request.pem is also generated with openssl. For CN, the full DNS name of the server must be entered.

openssl req -sha256 -new -key key.pem -out request.pem \
 -subj '/C=DE/ST=Schleswig-Holstein/L=Kiel/O=Christian-Albrechts-Universitaet zu Kiel/CN=myserver.uni-kiel.de'

Merging of certificate and private key

If the server software expects key and certificate in a merged p12 file, it can be generated from key.pem and cert-9999999.pem as follows

openssl pkcs12 -export -in cert-9999999.pem -inkey key.pem -out key-and-cert.p12

Creating a certificate request under Windows with certreq.exe

Preliminary remark: there is a GUI for the procedure here, namely the MMC snapin 'Certificates', there under 'More Actions', 'All Tasks', 'Advanced Operations', 'Create User-Defined Request...', but with the settings required under 'Details' it is not obvious how the german terms will correlate to the properties of the certificate request. We therefore recommend the following procedure with configuration via a text file:

On the Windows server to which the certificate is to apply, create a text file with the following content (apart from the server name, which must of course be adapted, and possibly the value for 'Exportable')

; Ich bin machineconf.inf
[Version]
Signature='$Windows NT$'

[NewRequest]
Subject = 'C=DE, ST=Schleswig-Holstein, L=Kiel, O=Christian-Albrechts-Universitaet zu Kiel, CN=myserver.uni-kiel.de'
Exportable = FALSE                  ; Private key is not exportable
KeyLength = 3072                    ; Common key sizes: 512, 1024, 2048, 4096, 8192, 16384
KeySpec = 0                         ; KEX, SIGN
MachineKeySet = True                ; The key belongs to a computer
SMIME = TRUE
RequestType = PKCS10
HashAlgorithm = SHA256
KeyUsageProperty = 0x07             ; decrypt signing key-exchange
KeyUsage = 0xA0                     ; Digital Signature, Key Encipherment

[Strings]
szSUBJECT_ALT_NAME  = '2.5.29.17'
;szMS_USER_PRINCIPAL_NAME = '1.3.6.1.4.1.311.20.2.3'

szENHANCED_KEY_USAGE = '2.5.29.37'
szCLIENT_AUTH = '1.3.6.1.5.5.7.3.2'
szEMAIL_PROTN = '1.3.6.1.5.5.7.3.4'
szSSH_CLIENT  = '1.3.6.1.5.5.7.3.21'
szSMARTCARD_LOGIN        = '1.3.6.1.4.1.311.20.2.2'
szWEBSERVER='1.3.6.1.5.5.7.3.1'

[EnhancedKeyUsageExtension]
OID = %szWEBSERVER%

[Extensions]

%szSUBJECT_ALT_NAME% = '{text}'
_continue_ = 'DNS=myserver.uni-kiel.de'

The command certreq -new -machine machineconf.inf csr.pem then generates the certificate request csr.pem, which can be uploaded at DFN. The private key is automatically stored in the shallows of the operating system's interior. The certificate sent by DFN must be given the file extension .cer instead of .pem and can then be imported by double-clicking. Windows automatically recognizes to which pending certificate request it belongs.