nerdexam
Linux_Foundation

LFCS · Question #425

What openssl command will generate a selfsigned test certificate?

The correct answer is A. openssl req new x509 key privkey.pem out cacert.pem days 365. A self-signed certificate can be generated using the openssl req command with the new and x509 options, specifying the private key and validity period.

Submitted by krish.m· Apr 18, 2026Service Configuration

Question

What openssl command will generate a selfsigned test certificate?

Options

  • Aopenssl req new x509 key privkey.pem out cacert.pem days 365
  • Bopenssl sign key privkey.pem out cacert.pem days 365
  • Copenssl req key privkey.pem out cacert.pem days 365
  • Dopenssl sign new x509 key privkey.pem out cacert.pem days 365

How the community answered

(31 responses)
  • A
    74% (23)
  • B
    3% (1)
  • C
    16% (5)
  • D
    6% (2)

Why each option

A self-signed certificate can be generated using the `openssl req` command with the `new` and `x509` options, specifying the private key and validity period.

Aopenssl req new x509 key privkey.pem out cacert.pem days 365Correct

The `openssl req` command is used for certificate requests. Adding the `-x509` option transforms the certificate request into a self-signed certificate directly, meaning the certificate is signed by the same private key that generates the request. The `new` subcommand initiates a new request, `key privkey.pem` provides the private key, and `days 365` sets the certificate's validity duration.

Bopenssl sign key privkey.pem out cacert.pem days 365

There is no standard `openssl sign` subcommand for generating certificates; signing operations are typically handled by `openssl x509` when acting as a CA, or by `openssl req -x509` for self-signing.

Copenssl req key privkey.pem out cacert.pem days 365

This command is missing the crucial `-x509` flag, which is required to instruct `openssl req` to produce a self-signed certificate instead of a Certificate Signing Request (CSR).

Dopenssl sign new x509 key privkey.pem out cacert.pem days 365

This option uses the non-existent `openssl sign` subcommand and incorrectly combines `new` with `x509` in a non-standard syntax.

Concept tested: OpenSSL self-signed certificate generation

Source: https://www.openssl.org/docs/manmaster/man1/req.html

Topics

#openssl#certificate generation#self-signed certificate#TLS/SSL

Community Discussion

No community discussion yet for this question.

Full LFCS Practice