Refactor and centralize self-signed certificate generation across Framework

Open
#22,011 4 comments 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

@kx7m2qd is already working on this.

Since Oct 17, 2026.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
18/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
ruby
Domain
backend, security

Research direction

Start with lib/msf/core/cert_provider.rb (Msf::Ssl::CertProvider) and the fallback in lib/msf/core/exploit/remote/http_server.rb and tcp_server.rb to see how certificates are produced today. The call sites span dozens of files, so the design of one shared generator has to come first; the issue does not yet specify that API. Done means a single generator is used by the listed components with tests covering key generation, SANs and expiry.

Written by the indexing model from the issue text.

Description

suggestion-feature

Description

Context

Currently, Framework has fragmented and incomplete support for generating self-signed certificates across several components (e.g., HTTPS-based payloads, fetch payloads, miscellaneous HTTPS servers).

During a recent PR discussion around MCP support, we identified that certificate generation logic is duplicated and less comprehensive than it could be. Instead of maintaining piecemeal implementations, we want to consolidate this capability into a single, feature-complete service.

Objectives
  • Centralize Certificate Generation: Create a single, standard utility/module within Framework responsible for producing self-signed certificates.
  • Expand Capabilities: Enhance the core certificate generation logic (e.g., proper key generation, SANs, configurable expiration) based on recent PR patterns.
  • Unify Existing Usage: Refactor existing Framework components to rely on this centralized generator rather than custom/partial implementations.
Affected Components / Call Sites

LLM-generated list, could be incomplete. This list

Automatic TLS
  • Framework TLS (encrypted transport) services use Msf::Ssl::CertProvider at lib/msf/core/cert_provider.rb:47. It is registered with Rex (Metasploit’s networking library) at lib/msf/core/framework.rb:83.
  • Generic HTTP and TCP server modules generate certificates when TLS is enabled without SSLCert. The controlling paths are lib/msf/core/exploit/remote/http_server.rb:122 and lib/msf/core/exploit/remote/tcp_server.rb:60. These mixins occur across 508 module files.
  • Eight additional modules create custom listeners through the same fallback: modules/exploits/osx/browser/safari_file_policy.rb:173, modules/auxiliary/gather/safari_file_url_navigation.rb:226, modules/auxiliary/gather/apple_safari_ftp_url_cookie_theft.rb:81, modules/exploits/multi/http/log4shell_header_injection.rb:260, modules/exploits/multi/upnp/libupnp_ssdp_overflow.rb:366, modules/exploits/linux/http/panos_readsessionvars.rb:178, modules/exploits/unix/misc/polycom_hdx_auth_bypass.rb:210, and modules/exploits/unix/misc/polycom_hdx_traceroute_exec.rb:149.
  • Credential Capture generates certificates for HTTPS, FTPS, IMAPS, POP3S, and SMTPS at plugins/capture.rb:213.
  • Reverse HTTPS and reverse TCP SSL handlers use generated listener certificates at lib/msf/core/handler/reverse_http.rb:241, lib/msf/core/handler/reverse_tcp_ssl.rb:56, and lib/msf/core/handler/reverse_tcp_double_ssl.rb:78.
  • HTTPS fetch payload adapters generate certificates through FetchSSLCert at lib/msf/core/payload/adapter/fetch/server/https.rb:15.
  • Meterpreter generates and caches its internal server certificate at lib/rex/post/meterpreter/client.rb:287.
  • Meterpreter and SSH pivoted TLS server channels use automatic certificates at lib/rex/post/meterpreter/extensions/stdapi/net/socket_subsystem/tcp_server_channel.rb:92 and lib/msf/base/sessions/ssh_command_shell_bind.rb:158.
  • MessagePack RPC (Remote Procedure Call) generates ephemeral certificates for msgrpc, default msfrpcd, and auto-started MCP. Relevant entry points are lib/msf/core/rpc/v10/service.rb:50, msfrpcd:147, and plugins/mcp.rb:563.
  • The msfd -s console daemon generates an ephemeral certificate through msfd:51 and plugins/msfd.rb:62.
  • The Metasploit web service generates persistent certificate files through msfdb:410. Thin and JSON-RPC consume them at msfdb:716 and msfrpcd:228.
Dedicated Generators
  • Android payload generation self-signs every generated APK/JAR at lib/msf/core/payload/android.rb:71.
  • Android template injection creates a KeyTool certificate and re-signs the APK at lib/msf/core/payload/apk.rb:285.
  • SCCM client registration uses a self-signed identity certificate at lib/msf/core/exploit/remote/http/sccm.rb:21.
  • Shadow Credentials creates a self-signed certificate for stored credential material at modules/auxiliary/admin/ldap/shadow_credentials.rb:251.
  • Both Cisco SD-WAN authentication bypass modules use self-signed DTLS certificates at modules/auxiliary/admin/networking/cisco_sdwan_auth_bypass.rb:125 and modules/auxiliary/admin/networking/cisco_sdwan_vhub_auth_bypass.rb:142.
  • HTTP SSL Certificate Impersonation creates self-signed loot when no private key is supplied at modules/auxiliary/gather/impersonate_ssl.rb:172.
  • OpenSSL Heartbeat Client Memory generates and transmits a certificate at modules/auxiliary/server/openssl_heartbeat_client_memory.rb:352.
  • OpenSSL Alternative Chains Forgery generates a self-signed CA (Certificate Authority) certificate at modules/auxiliary/server/openssl_altchainsforgery_mitm_proxy.rb:88.
  • Veritas Backup Exec Agent RCE generates and uses a self-signed CA at modules/exploits/multi/veritas/beagent_sha_auth_rce.rb:346.
  • Backup Exec SSL Use-After-Free generates and uses a self-signed CA at modules/exploits/windows/backupexec/ssl_uaf.rb:566.
  • The msfvenom APK Template Command Injection exploit signs its crafted APK at modules/exploits/unix/fileformat/metasploit_msfvenom_apk_template_cmd_injection.rb:63.
Target-Side Generation
  • Geutebruck CVE-2021-33544 invokes createselfcert at modules/exploits/linux/http/geutebruck_cmdinject_cve_2021_335xx.rb:54.
  • Cisco RV320/RV325 invokes self_generator.htm at modules/exploits/linux/http/cisco_rv32x_rce.rb:155.
  • Trend Micro IMSVA invokes its certificate generator at modules/exploits/linux/http/trend_micro_imsva_exec.rb:127, although the source does not establish whether certType=0 is self-signed.
Dominant language
Ruby
Stars
39.7k
Forks
15.1k
Avg merge
4d 2h
Merged PRs (30d)
71

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from rapid7/metasploit-framework

All issues in rapid7/metasploit-framework

Similar issues

More Ruby issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.