Etc ssl openssl cnf windows

  • Home
  • /

  • Blog
  • /

  • Step-By-Step Procedure to Install OpenSSL on a Windows Machine

Procedure To Install Openssl On The Windows Platform

OpenSSL is an open-source cryptographic library that provides a robust toolkit for securing communications and creating, managing, and verifying digital certificates. It is widely used for implementing Secure Sockets Layer (SSL) and Transport Layer Security (TLS) protocols to encrypt connections between clients and servers.

Some of the common uses of OpenSSL include setting up private certificate authorities, generating public/private key pairs, creating certificate signing requests, exporting private key from certificates, converting between certificate formats like PEM and PFX, validating SSL connections, and more.

In this comprehensive guide, we will cover how to download, install, and configure OpenSSL on Windows machines. While Linux distributions come with OpenSSL pre-installed, Windows users need to manually install OpenSSL by getting the binaries from trusted third-party sources.

We will go over the prerequisites, walk through the installation steps, explain how to set up environment variables, and verify the installation to ensure OpenSSL is ready to use on your Windows PC or server. Whether you are a developer, IT admin, or security professional, this step-by-step procedure will help you get OpenSSL running smoothly on your Windows systems.

What is OpenSSL and Why Should We Install OpenSSL on a Windows PC?

OpenSSL is an open-source cryptographic library that provides a robust toolkit for securing communications and applications. Though primarily used on Linux, installing OpenSSL on Windows unlocks powerful capabilities. OpenSSL is mostly for system administrators, developers, and Windows users who wants to implement SSL/TLS connections in their apps and scripts. It enables generating X.509 certificates and certificate signing requests (CSRs) for securing websites and internal infrastructure. Developers can call OpenSSL crypto functions to encrypt data and implement PKI authentication in their apps.

System administrators can manage certificates, test secure connections, and integrate OpenSSL into automation scripts. OpenSSL also helps troubleshoot connection issues by analyzing network traffic and certificates.

There are a lot of things you can do using OpenSSL. Only a few of them are listed here:

  1. You can create your own Certificate Authority and issue certificates on your network. 

  2. Convert digital certificates from one to another format. 

  3. Export or Import private keys from the certificates.

  4. Validate the HTTPS connections to the destination website.

  5. Verify the certificate of the destination website.

  6. Run benchmark tests of your server and remote website.

  7. Extract information like issuer, subject, issued and expiring dates, and fingerprint from certificates.

  8. Create CSR.

  9. Decode CSR and Certificates to verify contents.

You can enjoy the features of OpenSSL if you have installed it on your Windows machine. Before we begin the procedure to install OpenSSL on the Windows platform, let’s see the prerequisites.

Download OpenSSL Installer for Windows

Before we jump into the installation of OpenSSL on a Windows PC, let’s cover a few things about the Linux package. As we said in the introduction, OpenSSL will come as part of default installation packages in all the popular Linux distributions, even if you need a specific version of OpenSSL for your Linux machine, you can download the source code of OpenSSL on from its official website alternatively from here and compel it on Linux. 

Well, If you are looking to download the OpenSSL package for your Windows machine from its official website, you can’t. It’s because OpenSSL doesn’t release official OpenSSL installers for Windows. You should depend on a few third-party distributors who distribute OpenSSL installer files for Windows platforms. OpenSSL has published the list of all trusted third-party distributors on its Wiki page. Please download and install only from these listed third-party sites.

Disclaimer Message from OpenSSL: The listing of these third-party products does not imply any endorsement by the OpenSSL project, and these organizations are not affiliated in any way with OpenSSL other than by reference to their independent websites here. In particular, any donations or payments to any of these organizations will not be known to, seen by, or in any way benefit the OpenSSL project.
OpenSSL

Note: OpenSSL says none of these vendors are partnered with OpenSSL, so issues with these installers should be directly communicated with the distributors. OpenSSL doesn’t hold any responsibilities for these installers. Use these OpenSSL-derived products at your own risk; these products have not been evaluated or tested by the OpenSSL project.

List of Third-Party OpenSSL Distributions:

Product Description URL
OpenSSL for Web (using WebAssembly) OpenSSL 3.0 ported to WebAssembly (in October 2021). Uses Emscripten and xterm.js to emulate a terminal in your browser. WASI binaries are supported too. The Wasm execution happens using WebWorkers if the browser supports them. Originally developed for the cryptology playground “CrypTool-Online”. Code is open-source on GitHub. OpenSSL-React app: https://github.com/cryptool-org/openssl-webtermBasic Wasm terminal: https://github.com/cryptool-org/wasm-webtermRunning sample: https://www.cryptool.org/en/cto/openssl
OpenSSL for Windows Works with MSVC++, Builder 3/4/5, and MinGW. Comes in form of self-install executables. https://slproweb.com/products/Win32OpenSSL.html  
OpenSSL for Windows Pre-compiled Win32/64 libraries without external dependencies to the Microsoft Visual Studio Runtime DLLs, except for the system provided msvcrt.dll. https://indy.fulgan.com/SSL/  
OpenSSL for Windows Reproducible builds with latest MinGW-w64, 64/32-bit, static/dynamic libs and executable. https://github.com/curl/curl-for-win  
OpenSSL for Solaris Versions for Solaris 2.5 – 11 SPARC and X86 http://www.unixpackages.com/  
OpensSSL for Windows, Linux, OSX, Android Pre-compiled packages at conan.io package manager:Windows x86/x86_64 (Visual Studio 10, 12, 14, 15)Linux x86/x86_64 (gcc 4.6, 4.8, 4.9, 5, 6, 7)OSx (Apple clang).Cross-building ready recipe: Linux ARM, Android. https://www.conan.io  https://conan.io/center/openssl  
OpenSSL for Windows Pre-compiled Win32/64 1.0.2, 1.1.0, 1.1.1 and 3.0 libraries without external dependencies, primarily built for François Piette’s Internet Component Suite (ICS) for Embarcadero (Borland) Delphi and C++ development tools, but may be used for any Windows applications. The OpenSSL DLLs and EXE files are digitally code signed ‘Open Source Developer, François PIETTE’, so applications can self verify them for corruption. http://wiki.overbyte.eu/wiki/index.php/ICS_Download  
OpenSSL for Windows OpenSSL 3.1, 3.0, and 1.1.1 pre-compiled for Microsoft Windows with no external dependencies. The binary distributions can be used standalone or integrated into any Windows application. Installer, EXEs and DLLs are digitally signed with ‘FireDaemon Technologies Limited’ Extended Validation (EV) code signing certificate. https://www.firedaemon.com/get-openssl  
OpenSSL for NonStop Pre-compiled NonStop ia64/x86 1.0.2, 1.1.1 executables and libraries for the HPE NonStop Operating Systems. Threaded versions are included. The SPT version depends on FLOSS, otherwise there are no other dependencies. 32-bit versions are available. The builds are done by the ITUGLIB Technical Committee as part of Connect. https://ituglib.connect-community.org/apps/Ituglib/SrchOpenSrcLib.xhtml  

How To Install OpenSSL On The Windows Platform?

The installation procedure is very simple and straightforward. Since OpenSSL does not provide official Windows installers, you need to download OpenSSL from trusted third-party sources listed on the OpenSSL Wiki.

We used Windows 11 64-bit and OpenSSL v 3.1.3 in this tutorial post.

Step 1. Download OpenSSL Installer

Visit any of the above sites and download the appropriate OpenSSL installer for your Windows version (32-bit or 64-bit). Make sure to pick the correct installer package for your machine.

Step 2. Run the OpenSSL Installer

Once downloaded, run the OpenSSL installer (.exe file) by double-clicking on it.

Accept the license agreement and choose the installation directory. The default is C:\Program Files\OpenSSL-Win64 but you can customize it.

The installer will copy all the required DLLs, and libraries, including files and executables. The installation typically finishes within a minute.

Step 3. Installation in progress…….
Step 4. Finish OpenSSL Installation

Once the installation completes, the setup wizard will prompt you to finish the installation. Click Finish to complete the OpenSSL installation process.

Step 5. Set Environment Variable
If you just want to set the environment varibles only for a login session, then run these commands.

>set OPENSSL_CONF=C:\Program Files\OpenSSL-Win64\bin\openssl.cfg
>set Path= C:\Program Files\OpenSSL-Win64\bin

If you want to set the env variable for permanently, then add OPENSSL_CONF and Path environment variable on System Properties.

Open Run using ‘Windows’ + ‘r’ then type ‘sysdm.cpl‘. Go to Advanced > Environment Variable.

Set OPENSSL_CONF and Path variables.

Step 6. Verify the Installation

To verify that OpenSSL is installed correctly and added to PATH, open a new command prompt and run:

openssl version

This will print the installed OpenSSL version and confirm the installation was successful.

You can also check all available commands by running:

openssl help

This completes the installation of OpenSSL on Windows. You will see openssl.ext file in C:\Program Files\OpenSSL-Win64\bin directory.

Troubleshooting OpenSSL Issues

The real problem is not in installing OpenSSL on your Windows computer. The real problem encountered after the installation is when you start using OpenSSL. Many people reported that they were unable to run OpenSSL commands on their computers. This could be due to one of these reasons:

  • Incorrect environment variablesOpenSSL requires certain env vars like OPENSSL_CONF to be set properly. Not configuring these variables correctly can prevent things from working.

  • OpenSSL path not added – The OpenSSL install location needs to be added to the PATH env variable. Failing to do so will make the openssl command unrecognized.

  • Configuration issuesOpenSSL depends on its config file openssl.cnf. If this file is missing or corrupted, strange errors can occur.

  • Old OpenSSL versionOpenSSL releases new versions periodically with security fixes and improvements. Using an outdated OpenSSL can expose vulnerabilities. Upgrade to a newer version when possible.

  • Wrong architecture – Getting 32-bit and 64-bit versions mixed up can lead to errors. Make sure to install the version that matches your Windows architecture.

  • Missing DLL filesOpenSSL relies on certain DLL files like libeay32.dll and ssleay32.dll. If these files are missing or not in the system path, OpenSSL commands will fail.

The first thing you should do is to download the correct installer file and reinstall the OpenSSL. This solves problems like missing DLL and wrong architecture. Generally, version-related issues were seen least oftentimes. You can try fixing version-related issues by reinstalling a different version.

If your problem still persists, then the reason could either be with environment variables or OpenSSL configuration files. Let’s try to troubleshoot.

You should start troubleshooting by running openssl version command. If you get any error, ensure you configured OPENSSL_CONF and Path environment variable as per step 5. We should tell you about the two prominent configuration files openssl.cfg and openssl.cnf. People often get confused with these files. Just pay attention to the extensions .cfg and .cnf. You should set the environment variable OPENSSL_CONF to openssl.cfg file.

Let’s understand openssl.cfg and openssl.cnf configuration files in OpenSSL.

  • openssl.cfg – This is the default configuration file that comes with OpenSSL. It contains default settings for OpenSSL when no other config file is specified. The openssl.cfg file is located in the apps subfolder of the OpenSSL install directory.

  • openssl.cnf – This is the recommended main configuration file for OpenSSL. It contains sections for settings like certificate authority locations, certificate policies, default algorithms and protocols etc. The openssl.cnf file allows extensive customization of OpenSSL behavior.

It may sound similar. Let’s see the difference between to know more about these two files.

The main differences between openssl.cfg and openssl.cnf are:

  • openssl.cfg contains minimal default settings just to get OpenSSL working out of the box. openssl.cnf has extensive options to control OpenSSL behavior.

  • openssl.cfg is automatically loaded if no other config is specified. openssl.cnf must be explicitly specified using the -config option.

  • openssl.cfg is limited and intended for initial testing. openssl.cnf is meant for production use and customization.

  • openssl.cfg sets insecure default settings like using MD5 hashes. openssl.cnf has more conservative secure defaults.

  • Anything set in openssl.cnf will override the defaults in openssl.cfg. openssl.cnf is treated as the main config.

In Windows, openssl.cfg file is located at C:\Program Files\OpenSSL-Win64\bin directory. The openssl.cnf file is located at two locations: C:\Program Files\Common Files\SSL and C:\Program Files\OpenSSL-Win64\bin\cnf.

If you get an error messages “Can’t open /usr/lib/ssl/openssl.cnf for reading, No such file or directory” and “cannot access ‘/etc/ssl/openssl.cnf’: No such file or directory“. Make sure you have both files in their path and that environment variables are set.

If in case your openssl.cnf file is missing or unable to see, you can download openssl.cnf file from MIT (Massachusetts Institute of Technology). MIT provides a generic configuration file that you can use. You can download the file to these directories to fix the errors.

  • C:\Program Files\Common Files\SSL\

  • C:\Program Files\OpenSSL-Win64\bin\cnf\

If you set all these things, you are not going to see any issues in OpenSSL.

Bottom Line

Installing OpenSSL on Windows provides access to a robust cryptographic toolkit for secure communication and certificate management. This step-by-step guide covered downloading OpenSSL installers from the trusted third-party distributors, installing it on a Windows machine, setting up environment variables, and verifying the installation.

With OpenSSL added to your Windows desktop or server, you can now generate public/private key pairs, create and manage X.509 certificates, test SSL/TLS connections, implement encryption in your apps, and much more.

We hope this step-by-step procedure helps understand everything about the instillation of OpenSSL on a Windows machine. Thanks for reading this post. Please share this post and help secure the digital world. Visit our website, thesecmaster.com, and our social media page on FacebookLinkedInTwitterTelegramTumblrMedium, and Instagram and subscribe to receive updates like this.  

You may also like these articles:

Arun KL

Arun KL is a cybersecurity professional with 15+ years of experience in IT infrastructure, cloud security, vulnerability management, Penetration Testing, security operations, and incident response. He is adept at designing and implementing robust security solutions to safeguard systems and data. Arun holds multiple industry certifications including CCNA, CCNA Security, RHCE, CEH, and AWS Security.

As several things have changed since I published “Howto: Make Your Own Cert With OpenSSL on Windows” 5 years ago, I’m publishing an updated how-to.

This time, I’m using the OpenSSL Windows binaries provided by the Curl developers:

I’m using OpenSSL version 1.1.1i. I chose the 32-bit version, so that you can still follow along in case you have to do this on a 32-bit computer.

This OpenSSL version from the Curl developers is packaged inside a ZIP file: it requires no installation with administrative rights. Just unzip the downloaded file.

Then open a command-line (I’m using cmd.exe) and go to the unzipped folder:

I issue the command “openssl version”, to check that I can run OpenSSL.

Now you are ready to follow along.

And just like in my previous how-to(s), I’m creating 2 certificates (not just one self-signed certificate): one root certificate and one subordinate certificate.

First we generate a 4096-bit long RSA key for our root CA and store it in file ca.key:

openssl genrsa -out ca.key 4096

This generates a private key that is not password protected. It is stored inside file ca.key as printable text (PEM format):

If you want to password-protect this private key, add command option -aes256 to encrypt the private key with AES using a key derived from a password you will be prompted for.

Next, we create our self-signed root CA certificate ca.crt; you’ll need to provide an identity for your root CA:

openssl req -new -x509 -days 1826 -key ca.key -out ca.crt -config openssl.cnf

The -x509 command option is used for a self-signed certificate. 1826 days gives us a cert valid for 5 years.

On Windows, you can double-click the root certificate we just created (ca.crt), and inspect it:

Next step: create our subordinate CA that will be used for the actual signing. First, generate the key:

openssl genrsa -out ia.key 4096

Then, request a certificate for this subordinate CA:

openssl req -new -key ia.key -out ia.csr -config openssl.cnf

Make sure that the Common Name you enter here is different from the Common Name you entered previously for the root CA. If they are the same, you will get an error later on when creating the pkcs12 file.

Next step: process the request for the subordinate CA certificate and get it signed by the root CA.

Here the command requires an extra option, that I did not use in previous how-tos. We need a small text file (altname.cnf), with the following content:

subjectAltName=DNS:www.didierstevens.com

I use the same value as I used for the Common Name (CN): http://www.didierstevens.com.

This subjectAltName is necessary, since Google Chrome version 58 and later no longer use the CN when there is no subjectAltName.

After creating this altname.cnf file, we can issue this command to create the subordinate CA signed by the root CA:

openssl x509 -req -days 730 -in ia.csr -CA ca.crt -CAkey ca.key -set_serial 01 -out ia.crt -extfile altname.cnf

The certificate (ia.crt) will be valid for 2 years (730 days) and I decided to choose my own serial number 01 for this cert (-set_serial 01). For the root CA, I let OpenSSL generate a random serial number.

You can also inspect this certificate (ia.crt) with Windows:

That’s all there is to it! Of course, there are many options I didn’t use. Consult the OpenSSL documentation for more info. For example, I didn’t restrict my subordinate CA key usage to digital signatures. It can be used for anything, even making another subordinate CA. When you buy a code signing certificate, the CA company will limit its use to code signing. And I did not use passwords to protect my keys. In a production environment, you want to protect your keys with passwords.

To use this subordinate CA key for Authenticode signatures with Microsoft’s signtool, you’ll have to package the keys and certs in a PKCS12 file:

openssl pkcs12 -export -out ia.p12 -inkey ia.key -in ia.crt -chain -CAfile ca.crt

Then it can be used to sign a Windows PE file:

signtool sign /f ia.p12 /fd sha256 /td sha256 /tr http://timestamp.globalsign.com/?signature=sha2 Dialog42.exe

Some Observations

Configuration file

Some OpenSSL commands (like the req command we used) require the openssl.cnf configuration file. That is why on Windows, we use command option: -config openssl.cnf

If we do not use this command option on Windows, we get an error:

Can't open C:/Windows/System32/OpenSSL/ssl/openssl.cnf for reading, No such file or directory
22256:error:02001003:system library:fopen:No such process::0:fopen('C:/Windows/System32/OpenSSL/ssl/openssl.cnf','r')
22256:error:2006D080:BIO routines:BIO_new_file:no such file::0:

Even if we run openssl.exe in the same folder as openssl.cnf.

Another option is to set environment variable OPENSSL_CONF to point to the configuration file:

set OPENSSL_CONF= c:\Demo\openssl-1.1.1i_2-win32-mingw\openssl.cnf

Then we can issue commands without referencing the openssl.cnf explicitly:

Command option subj

When we use command req like we did, we are prompted for extra information. This extra information can be passed via the command line too, with command option -subj:

openssl req -new -x509 -days 1826 -key ca.key -out ca.crt -subj “/C=BE/ST=/L=Brussels/O=Didier Stevens/OU=/CN=didierstevens.com/emailAddress=ca@didierstevens.com” -config openssl.cnf

Do not use interactive mode

Interactive mode in OpenSSL, is when you launch opensll.exe, and then issue commands at the OpenSSL prompt, like this:

The error message:

problem creating object tsa_policy1=1.2.3.4.1
25156:error:08064066:object identifier routines:OBJ_create:oid exists::0:
error in req

is a known issue with OpenSSL.

Interactive mode doesn’t “clean up” correctly between commands: it is best not to use interactive mode.

Certificates with a validity period longer than one year

I know that Chrome is no longer accepting certificates with a validity period longer than one year, so I expected my 2-year certificate to be rejected by Chrome (using Chrome 87 on Windows). It was not.

It turns out that this requirement does not apply to certificates like the one I created:

Beginning with Chrome 85, TLS server certificates issued on or after 2020-09-01 00:00:00 UTC will be required to have a validity period of 398 days or less. This will only apply to TLS server certificates from CAs that are trusted in a default installation of Google Chrome, commonly known as “publicly trusted CAs”, and will not apply to locally-operated CAs that have been manually configured.

X.509 Version 1 and Version 3

In my previous blog posts on OpenSSL, the created root certificates (ca.crt) are X.509 Version 3 certificates, and the created subordinate certificates (ia.crt) are X.509 Version 1 certificates. That’s because I did not use any version 3 extensions for the subordinate certificates, and thus OpenSSL creates version 1 certificates.

This changes with the use of the Subject Alternative Name (SAN) extension (subjectAltName) in this how-to. subjectAltName is a version 3 extension, and thus the subordinate certificate (ia.crt) created in this how-to is a version 3 X.509 certificate. In this how-to, I had only one Common Name and therefore I used just one SAN: DNS:www.didierstevens.com.

It is possible to use several SANs, and not only DNS, but also IP for example:

subjectAltName=DNS:www.didierstevens.com,DNS:*.didierstevens.be,IP:127.0.0.1

There are also version 3 extensions that dictate what a certificate can be used for. When these extensions are not present, a certificate can be used for everything.

If you want to limit the use of a certificate to web servers, you can use the following values:

basicConstraints = CA:FALSE
keyUsage = nonRepudiation, digitalSignature, keyEncipherment
extendedKeyUsage=serverAuth
subjectAltName=DNS:www.didierstevens.com

This one can not be used for code signing:

SignTool Error: No certificates were found that met all the given criteria.

And you can use the following values to limit the use of a certificate to code signing:

basicConstraints = CA:FALSE
keyUsage = digitalSignature
extendedKeyUsage=codeSigning

Caveat: I just did some basic tests with these extensions. For example, the cert restricted to code signing can be used by signtool, and Chrome will refuse it when I use it with my simple web server. I didn’t do exhaustive testing to see if code signing is the only thing this cert can be used for.

I did compare it with a commercial code signing certificate I acquired years ago, and there was a difference for the keyUsage: it was marked as critical.

basicConstraints = CA:FALSE
keyUsage = critical,digitalSignature
extendedKeyUsage=codeSigning

Installing the root certificate

When you use the subordinate certificate, you will see that it is still rejected by web browsers, and that the Authenticode signature is not valid.

That is because the subordinate’s root certificate is not trusted. If you install it as a trusted root certification authority, the subordinate certificate will be trusted.

Linux

You can use the same commands on a Linux machine where the OpenSSL package is installed.

Don’t use command option -config though: openssl will find its config file.

And I got an issue with the command option -subj and “empty strings”:

problems making Certificate Request
140254820331968:error:0D07A098:asn1 encoding routines:ASN1_mbstring_ncopy:string too short:../crypto/asn1/a_mbstr.c:100:minsize=1

I had to remove ST= and OU=.

Tips and Tricks

I faced the above issue while trying to use openssl in window. I have downloaded openssl and extracted in my windows server. After that I tried executing the following command.

openssl.exe genrsa -out subdomain.mydomain.com.key 2048

Solution:

Open Powershell

set OPENSSL_CONF=c:\[PATH TO YOUR OPENSSL DIRECTORY]\bin\openssl.cnf

Now execute the openssl command to generate the certificate. It will work without any issues. I hope this is helpful.

NAME¶

config — OpenSSL CONF library configuration files

DESCRIPTION¶

This page documents the syntax of OpenSSL configuration files, as parsed by NCONF_load(3) and related functions. This format is used by many of the OpenSSL commands, and to initialize the libraries when used by any application.

The first part describes the general syntax of the configuration files, and subsequent sections describe the semantics of individual modules. Other modules are described in fips_config(5) and x509v3_config(5). The syntax for defining ASN.1 values is described in ASN1_generate_nconf(3).

SYNTAX¶

A configuration file is a series of lines. Blank lines, and whitespace between the elements of a line, have no significance. A comment starts with a # character; the rest of the line is ignored. If the # is the first non-space character in a line, the entire line is ignored.

Directives¶

Two directives can be used to control the parsing of configuration files: .include and .pragma.

For compatibility with older versions of OpenSSL, an equal sign after the directive will be ignored. Older versions will treat it as an assignment, so care should be taken if the difference in semantics is important.

A file can include other files using the include syntax:

If pathname is a simple filename, that file is included directly at that point. Included files can have .include statements that specify other files. If pathname is a directory, all files within that directory that have a .cnf or .conf extension will be included. (This is only available on systems with POSIX IO support.) Any sub-directories found inside the pathname are ignored. Similarly, if a file is opened while scanning a directory, and that file has an .include directive that specifies a directory, that is also ignored.

As a general rule, the pathname should be an absolute path; this can be enforced with the abspath and includedir pragmas, described below. The environment variable OPENSSL_CONF_INCLUDE, if it exists, is prepended to all relative pathnames. If the pathname is still relative, it is interpreted based on the current working directory.

To require all file inclusions to name absolute paths, use the following directive:

.pragma [=] abspath:value

The default behavior, where the value is false or off, is to allow relative paths. To require all .include pathnames to be absolute paths, use a value of true or on.

In these files, the dollar sign, $, is used to reference a variable, as described below. On some platforms, however, it is common to treat $ as a regular character in symbol names. Supporting this behavior can be done with the following directive:

.pragma [=] dollarid:value

The default behavior, where the value is false or off, is to treat the dollarsign as indicating a variable name; foo$bar is interpreted as foo followed by the expansion of the variable bar. If value is true or on, then foo$bar is a single seven-character name and variable expansions must be specified using braces or parentheses.

.pragma [=] includedir:value

If a relative pathname is specified in the .include directive, and the OPENSSL_CONF_INCLUDE environment variable doesn’t exist, then the value of the includedir pragma, if it exists, is prepended to the pathname.

Settings¶

A configuration file is divided into a number of sections. A section begins with the section name in square brackets, and ends when a new section starts, or at the end of the file. The section name can consist of alphanumeric characters and underscores. Whitespace between the name and the brackets is removed.

The first section of a configuration file is special and is referred to as the default section. This section is usually unnamed and spans from the start of file until the first named section. When a name is being looked up, it is first looked up in the current or named section, and then the default section if necessary.

The environment is mapped onto a section called ENV.

Within a section are a series of name/value assignments, described in more detail below. As a reminder, the square brackets shown in this example are required, not optional:

[ section ]
name1 = This is value1
name2 = Another value
...
[ newsection ]
name1 = New value1
name3 = Value 3

The name can contain any alphanumeric characters as well as a few punctuation symbols such as . , ; and _. Whitespace after the name and before the equal sign is ignored.

If a name is repeated in the same section, then all but the last value are ignored. In certain circumstances, such as with Certificate DNs, the same field may occur multiple times. In order to support this, commands like openssl-req(1) ignore any leading text that is preceded with a period. For example:

1.OU = First OU
2.OU = Second OU

The value consists of the string following the = character until end of line with any leading and trailing whitespace removed.

The value string undergoes variable expansion. The text $var or ${var} inserts the value of the named variable from the current section. To use a value from another section use $section::name or ${section::name}. By using $ENV::name, the value of the specified environment variable will be substituted.

Variables must be defined before their value is referenced, otherwise an error is flagged and the file will not load. This can be worked around by specifying a default value in the default section before the variable is used.

Any name/value settings in an ENV section are available to the configuration file, but are not propagated to the environment.

It is an error if the value ends up longer than 64k.

It is possible to escape certain characters by using a single or double « quote around the value, or using a backslash \ before the character, By making the last character of a line a \ a value string can be spread across multiple lines. In addition the sequences \n, \r, \b and \t are recognized.

The expansion and escape rules as described above that apply to value also apply to the pathname of the .include directive.

OPENSSL LIBRARY CONFIGURATION¶

The sections below use the informal term module to refer to a part of the OpenSSL functionality. This is not the same as the formal term FIPS module, for example.

The OpenSSL configuration looks up the value of openssl_conf in the default section and takes that as the name of a section that specifies how to configure any modules in the library. It is not an error to leave any module in its default configuration. An application can specify a different name by calling CONF_modules_load_file(), for example, directly.

OpenSSL also looks up the value of config_diagnostics. If this exists and has a nonzero numeric value, any error suppressing flags passed to CONF_modules_load() will be ignored. This is useful for diagnosing misconfigurations but its use in production requires additional consideration. With this option enabled, a configuration error will completely prevent access to a service. Without this option and in the presence of a configuration error, access will be allowed but the desired configuration will not be used.

# These must be in the default section
config_diagnostics = 1
openssl_conf = openssl_init

[openssl_init]
oid_section = oids
providers = providers
alg_section = evp_properties
ssl_conf = ssl_configuration
engines = engines
random = random

[oids]
... new oids here ...

[providers]
... provider stuff here ...

[evp_properties]
... EVP properties here ...

[ssl_configuration]
... SSL/TLS configuration properties here ...

[engines]
... engine properties here ...

[random]
... random properties here ...

The semantics of each module are described below. The phrase «in the initialization section» refers to the section identified by the openssl_conf or other name (given as openssl_init in the example above). The examples below assume the configuration above is used to specify the individual sections.

ASN.1 Object Identifier Configuration¶

The name oid_section in the initialization section names the section containing name/value pairs of OID’s. The name is the short name; the value is an optional long name followed by a comma, and the numeric value. While some OpenSSL commands have their own section for specifying OID’s, this section makes them available to all commands and applications.

[oids]
shortName = a very long OID name, 1.2.3.4
newoid1 = 1.2.3.4.1
some_other_oid = 1.2.3.5

If a full configuration with the above fragment is in the file example.cnf, then the following command line:

OPENSSL_CONF=example.cnf openssl asn1parse -genstr OID:1.2.3.4.1

will output:

0:d=0  hl=2 l=   4 prim: OBJECT            :newoid1

showing that the OID «newoid1» has been added as «1.2.3.4.1».

Provider Configuration¶

The name providers in the initialization section names the section containing cryptographic provider configuration. The name/value assignments in this section each name a provider, and point to the configuration section for that provider. The provider-specific section is used to specify how to load the module, activate it, and set other parameters.

Within a provider section, the following names have meaning:

  • identity

    This is used to specify an alternate name, overriding the default name specified in the list of providers. For example:

    [providers]
    foo = foo_provider
    
    [foo_provider]
    identity = my_fips_module
    
  • module

    Specifies the pathname of the module (typically a shared library) to load.

  • activate

    If present and set to one of the values yes, on, true or 1, then the associated provider will be activated. Conversely, setting this value to no, off, false, or 0 will prevent the provider from being activated. Settings can be given in lower or uppercase. Setting activate to any other setting, or omitting a setting value will result in an error.

    = item soft_load

    If enabled, informs the library to clear the error stack on failure to activate requested provider. A value of 1, yes, true or on (in lower or uppercase) will activate this setting, while a value of 0, no, false, or off (again in lower or uppercase) will disable this setting. Any other value will produce an error. Note this setting defaults to off if not provided

All parameters in the section as well as sub-sections are made available to the provider.

Default provider and its activation¶

If no providers are activated explicitly, the default one is activated implicitly. See OSSL_PROVIDER-default(7) for more details.

If you add a section explicitly activating any other provider(s), you most probably need to explicitly activate the default provider, otherwise it becomes unavailable in openssl. It may make the system remotely unavailable.

EVP Configuration¶

The name alg_section in the initialization section names the section containing algorithmic properties when using the EVP API.

Within the algorithm properties section, the following names have meaning:

  • default_properties

    The value may be anything that is acceptable as a property query string for EVP_set_default_properties().

  • fips_mode (deprecated)

    The value is a boolean that can be yes or no. If the value is yes, this is exactly equivalent to:

    default_properties = fips=yes
    

    If the value is no, nothing happens. Using this name is deprecated, and if used, it must be the only name in the section.

SSL Configuration¶

The name ssl_conf in the initialization section names the section containing the list of SSL/TLS configurations. As with the providers, each name in this section identifies a section with the configuration for that name. For example:

[ssl_configuration]
server = server_tls_config
client = client_tls_config
system_default = tls_system_default

[server_tls_config]
... configuration for SSL/TLS servers ...

[client_tls_config]
... configuration for SSL/TLS clients ...

The configuration name system_default has a special meaning. If it exists, it is applied whenever an SSL_CTX object is created. For example, to impose system-wide minimum TLS and DTLS protocol versions:

[tls_system_default]
MinProtocol = TLSv1.2
MinProtocol = DTLSv1.2

The minimum TLS protocol is applied to SSL_CTX objects that are TLS-based, and the minimum DTLS protocol to those are DTLS-based. The same applies also to maximum versions set with MaxProtocol.

Each configuration section consists of name/value pairs that are parsed by SSL_CONF_cmd(3), which will be called by SSL_CTX_config() or SSL_config(), appropriately. Note that any characters before an initial dot in the configuration section are ignored, so that the same command can be used multiple times. This probably is most useful for loading different key types, as shown here:

[server_tls_config]
RSA.Certificate = server-rsa.pem
ECDSA.Certificate = server-ecdsa.pem

Engine Configuration¶

The name engines in the initialization section names the section containing the list of ENGINE configurations. As with the providers, each name in this section identifies an engine with the configuration for that engine. The engine-specific section is used to specify how to load the engine, activate it, and set other parameters.

Within an engine section, the following names have meaning:

  • engine_id

    This is used to specify an alternate name, overriding the default name specified in the list of engines. If present, it must be first. For example:

    [engines]
    foo = foo_engine
    
    [foo_engine]
    engine_id = myfoo
    
  • dynamic_path

    This loads and adds an ENGINE from the given path. It is equivalent to sending the ctrls SO_PATH with the path argument followed by LIST_ADD with value 2 and LOAD to the dynamic ENGINE. If this is not the required behaviour then alternative ctrls can be sent directly to the dynamic ENGINE using ctrl commands.

  • init

    This specifies whether to initialize the ENGINE. If the value is 0 the ENGINE will not be initialized, if the value is 1 an attempt is made to initialize the ENGINE immediately. If the init command is not present then an attempt will be made to initialize the ENGINE after all commands in its section have been processed.

  • default_algorithms

    This sets the default algorithms an ENGINE will supply using the function ENGINE_set_default_string().

All other names are taken to be the name of a ctrl command that is sent to the ENGINE, and the value is the argument passed with the command. The special value EMPTY means no value is sent with the command. For example:

[engines]
foo = foo_engine

[foo_engine]
dynamic_path = /some/path/fooengine.so
some_ctrl = some_value
default_algorithms = ALL
other_ctrl = EMPTY

Random Configuration¶

The name random in the initialization section names the section containing the random number generator settings.

Within the random section, the following names have meaning:

  • random

    This is used to specify the random bit generator. For example:

    [random]
    random = CTR-DRBG
    

    The available random bit generators are:

    • CTR-DRBG
    • HASH-DRBG
    • HMAC-DRBG
  • cipher

    This specifies what cipher a CTR-DRBG random bit generator will use. Other random bit generators ignore this name. The default value is AES-256-CTR.

  • digest

    This specifies what digest the HASH-DRBG or HMAC-DRBG random bit generators will use. Other random bit generators ignore this name.

  • properties

    This sets the property query used when fetching the random bit generator and any underlying algorithms.

  • seed

    This sets the randomness source that should be used. By default SEED-SRC will be used outside of the FIPS provider. The FIPS provider uses call backs to access the same randomness sources from outside the validated boundary.

  • seed_properties

    This sets the property query used when fetching the randomness source.

  • random_provider

    This sets the provider to use for the RAND_bytes(3) calls instead of the built-in entropy sources. It defaults to «fips». If the named provider is not loaded, the built-in entropy sources will be used.

EXAMPLES¶

This example shows how to use quoting and escaping.

# This is the default section.
HOME = /temp
configdir = $ENV::HOME/config

[ section_one ]
# Quotes permit leading and trailing whitespace
any = " any variable name "
other = A string that can \
cover several lines \
by including \\ characters
message = Hello World\n

[ section_two ]
greeting = $section_one::message

This example shows how to expand environment variables safely. In this example, the variable tempfile is intended to refer to a temporary file, and the environment variable TEMP or TMP, if present, specify the directory where the file should be put. Since the default section is checked if a variable does not exist, it is possible to set TMP to default to /tmp, and TEMP to default to TMP.

# These two lines must be in the default section.
TMP = /tmp
TEMP = $ENV::TMP

# This can be used anywhere
tmpfile = ${ENV::TEMP}/tmp.filename

This example shows how to enforce FIPS mode for the application sample.

sample = fips_config

[fips_config]
alg_section = evp_properties

[evp_properties]
default_properties = "fips=yes"

ENVIRONMENT¶

  • OPENSSL_CONF

    The path to the config file, or the empty string for none. Ignored in set-user-ID and set-group-ID programs.

  • OPENSSL_ENGINES

    The path to the engines directory. Ignored in set-user-ID and set-group-ID programs.

  • OPENSSL_MODULES

    The path to the directory with OpenSSL modules, such as providers. Ignored in set-user-ID and set-group-ID programs.

  • OPENSSL_CONF_INCLUDE

    The optional path to prepend to all .include paths.

BUGS¶

There is no way to include characters using the octal \nnn form. Strings are all null terminated so nulls cannot form part of the value.

The escaping isn’t quite right: if you want to use sequences like \n you can’t use any quote escaping on the same line.

The limit that only one directory can be opened and read at a time can be considered a bug and should be fixed.

HISTORY¶

An undocumented API, NCONF_WIN32(), used a slightly different set of parsing rules there were intended to be tailored to the Microsoft Windows platform. Specifically, the backslash character was not an escape character and could be used in pathnames, only the double-quote character was recognized, and comments began with a semi-colon. This function was deprecated in OpenSSL 3.0; applications with configuration files using that syntax will have to be modified.

SEE ALSO¶

openssl-x509(1), openssl-req(1), openssl-ca(1), openssl-fipsinstall(1), ASN1_generate_nconf(3), EVP_set_default_properties(3), CONF_modules_load(3), CONF_modules_load_file(3), RAND_bytes(3), fips_config(5), and x509v3_config(5).

COPYRIGHT¶

Copyright 2000-2025 The OpenSSL Project Authors. All Rights Reserved.

Licensed under the Apache License 2.0 (the «License»). You may not use this file except in compliance with the License. You can obtain a copy in the file LICENSE in the source distribution or at https://www.openssl.org/source/license.html.

published under license CC4-BY

posted at 18. Jun ’23

I use a project which generates NTLM passwords (“Windows Sharing” feature) for users with https://github.com/krissi/ruby-smbhash, so they can log into a Samba server. OpenSSL with version 3 moved old cryptographic algorithms into a legacy provider which needs to be loaded explicitly.

OpenSSL 3 is in distros now (like Debian 12) and also in rbenv build — https://github.com/rbenv/ruby-build/pull/2000/files for Ruby 3.x.

The project is written in Ruby and there should be two options:

  1. edit /etc/ssl/openssl.cnf and load legacy provider there
  2. activate legacy provider in Ruby code — not possible yet — https://github.com/ruby/openssl/pull/635

I’ll do 1. and change the configuration file.

Check If Legacy Provider Is Already Activated

echo -n "aaa" | openssl md4
Error setting digest
40073CB3CE7F0000:error:0308010C:digital envelope routines:inner_evp_generic_fetch:unsupported:../crypto/evp/evp_fetch.c:373:Global default library context, Algorithm (MD4 : 88), Properties ()
40073CB3CE7F0000:error:03000086:digital envelope routines:evp_md_init_internal:initialization error:../crypto/evp/digest.c:254:
OpenSSL::Digest::MD4.new('aaa')
/home/damon/.rbenv/versions/3.2.2/lib/ruby/3.2.0/openssl/digest.rb:35:in `initialize': Digest initialization failed: initialization error (OpenSSL::Digest::DigestError)
openssl list -providers
Providers:
  default
    name: OpenSSL Default Provider
    version: 3.0.9
    status: active

It is not.

echo -n "aaa" | openssl md4 -provider legacy
MD4(stdin)= 918d7099b77c7a06634c62ccaf5ebac7

But it is at least compiled.

Change The Configuration File

As root:

Replace

[openssl_init]
# providers = provider_sect

# List of providers to load
# [provider_sect]
# default = default_sect
# The fips section name should match the section name inside the
# included fipsmodule.cnf.
# fips = fips_sect

# If no providers are activated explicitly, the default one is activated implicitly.
# See man 7 OSSL_PROVIDER-default for more details.
#
# If you add a section explicitly activating any other provider(s), you most
# probably need to explicitly activate the default provider, otherwise it
# becomes unavailable in openssl.  As a consequence applications depending on
# OpenSSL may not work correctly which could lead to significant system
# problems including inability to remotely access the system.
# [default_sect]
# activate = 1

With

[openssl_init]
providers = provider_sect

# List of providers to load
[provider_sect]
default = default_sect
legacy = legacy_sect

# The fips section name should match the section name inside the
# included fipsmodule.cnf.
# fips = fips_sect

# If no providers are activated explicitly, the default one is activated implicitly.
# See man 7 OSSL_PROVIDER-default for more details.
#
# If you add a section explicitly activating any other provider(s), you most
# probably need to explicitly activate the default provider, otherwise it
# becomes unavailable in openssl.  As a consequence applications depending on
# OpenSSL may not work correctly which could lead to significant system
# problems including inability to remotely access the system.
[default_sect]
activate = 1

[legacy_sect]
activate = 1

Test Newly Activated Legacy Provider

echo -n "aaa" | openssl md4
MD4(stdin)= 918d7099b77c7a06634c62ccaf5ebac7
OpenSSL::Digest::MD4.new('aaa').hexdigest
=> "918d7099b77c7a06634c62ccaf5ebac7"
openssl list -providers
Providers:
  default
    name: OpenSSL Default Provider
    version: 3.0.9
    status: active
  legacy
    name: OpenSSL Legacy Provider
    version: 3.0.9
    status: active

And that’s it. Legacy provider is loaded, I can use MD4 and tests pass.

References:

  • https://www.practicalnetworking.net/practical-tls/openssl-3-and-legacy-providers/
  • https://github.com/rbenv/ruby-build/pull/2000/files
  • https://github.com/ruby/openssl/pull/635
  • https://github.com/rapid7/metasploit-framework/pull/16800/files
  • https://www.openssl.org/docs/man3.0/man7/OSSL_PROVIDER-legacy.html
  • https://www.openssl.org/news/openssl-3.0-notes.html
  • https://github.com/krissi/ruby-smbhash/blob/master/lib/smbhash.rb

Add Comment

Comments (5)

RShields

Posted: 2024-03-22 18:08:49 UTC / Approved: 2024-07-30 19:59:41 UTC

I found that adding `OpenSSL::Provider.load(‘legacy’)` at the top of the .rb works on Windows

mptito (EDIT: email removed)

Posted: 2024-02-29 00:58:04 UTC / Approved: 2024-07-30 20:12:43 UTC

hey man i tried doing this but for some reason it doesnt work….??? any idea why?

Shtirlic

Posted: 2024-02-09 18:59:26 UTC / Approved: 2024-07-30 20:21:50 UTC

Now you can do OpenSSL::Provider.load(‘legacy’)
gem version openssl 3.2

xHire

Posted: 2024-01-13 20:18:31 UTC / Approved: 2024-01-13 22:49:51 UTC

Hey!

Thank you so much for this post, you saved me hours and hours of troubleshooting!

My error was `Neither PUB key nor PRIV key: bad decrypt (OpenSSL::PKey::RSAError)` – who would have thought that the cause is a missing provider, becase RSA is legacy now or something… Anyway, I’ve put more info about my use case to my blog: https://www.semirocket.science/noteblog/2024/01/ruby-openssl-3.0-neither-pub-key-nor-priv-key-bad-decrypt-openssl-pkey-rsaerror/

Thanks!

Darshan

Posted: 2024-01-04 22:51:31 UTC / Approved: 2024-07-30 20:31:29 UTC

this is awesome! THanks for you providing some helpful information in how to enable md4 !!

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Лучшие темы для windows 10 20h2
  • Windows 10 пуск не закрывается
  • Яндекс облако для windows
  • Windows 10 не могу загрузить профиль пользователя
  • Как создать символьную ссылку в windows 10