XK0-006 Security Practice Question
An administrator needs to generate a self-signed certificate valid for 365 days with a 2048-bit RSA key. Which OpenSSL command correctly creates both the private key and certificate in one step?
⚠ Common exam trap
XK0-006 often tests the confusion between generating a self-signed certificate in one step versus using separate commands, and the role of the -nodes flag.
Answer choices
Why each option matters
Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.
Correct answer & explanation
✓
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes
The command 'openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes' generates a new 2048-bit RSA private key and a self-signed certificate in one step. The -x509 option outputs a self-signed certificate instead of a certificate request, and -nodes ensures the private key is not encrypted. This matches the requirement to create both the private key and certificate simultaneously.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✓
openssl req -x509 -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365 -nodes
Why this is correct
Combines key generation and self-signing in a single invocation: -newkey rsa:2048 creates the 2048-bit RSA private key, -x509 emits a self-signed certificate rather than a CSR, -days 365 sets validity, and -nodes omits key encryption.
- ✗
openssl x509 -req -in req.pem -signkey key.pem -out cert.pem -days 365
Why it's wrong here
This signs an existing CSR, so it cannot create the private key and certificate in one step as required; it presumes key.pem and req.pem already exist. It is tempting because x509 -req is the standard way to sign a CSR with a self-signed key, which is correct when a CSR has already been generated separately.
- ✗
openssl ca -newkey rsa:2048 -keyout key.pem -out cert.pem -days 365
Why it's wrong here
The ca subcommand signs certificate requests against an existing CA database and configuration, so it cannot generate a fresh self-signed key pair in one step. It is tempting because ca does issue certificates, and it would be correct when signing a CSR with a pre-existing certificate authority rather than creating a standalone self-signed pair.
- ✗
openssl genrsa -out key.pem 2048 && openssl req -new -x509 -key key.pem -out cert.pem -days 365
Why it's wrong here
This runs two separate commands chained together, so it does not create the key and certificate in one step as the question requires. It is tempting because the resulting key and certificate are technically valid, and it would be correct if the task allowed multiple sequential OpenSSL invocations.
Quick reference
Asymmetric Encryption Algorithm Comparison
| Algorithm | Key Exchange | Signatures | Equivalent Security Key | Notes |
|---|---|---|---|---|
| RSA-3072 | Yes | Yes | 128-bit | Widely deployed; slow for bulk data |
| ECDSA P-256 | No | Yes | 128-bit | Fast signatures; standard TLS certs |
| ECDH / ECDHE | Yes | No | 128-bit | Perfect forward secrecy in TLS 1.3 |
| DH / DHE | Yes | No | 128-bit (3072-bit key) | Replaced by ECDHE in modern TLS |
| Ed25519 | No | Yes | ~128-bit | SSH keys, modern PKI |
About these practice questions
This XK0-006 question is part of Courseiva's 781-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →
JA
Written and reviewed by Johnson Ajibi, MSc IT Security
Senior Network & Security Engineer · founder of Courseiva
Last reviewed September 2026 · checked against the official CompTIA exam blueprint
This XK0-006 practice question is part of Courseiva's free CompTIA certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the XK0-006 exam.