> ## Documentation Index
> Fetch the complete documentation index at: https://docs.mainwp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# MainWP connection security

> How MainWP secures communication between Dashboard and Child Sites using password authentication, digital signatures, and HTTPS.

MainWP authenticates site connections and signs subsequent requests from MainWP Dashboard. Use HTTPS URLs for your child sites to encrypt requests and responses in transit.

## What You'll Learn

* How MainWP secures the initial site connection
* How MainWP requires at least one initial connection authentication method
* How HTTPS encrypts Dashboard-to-Child traffic
* How request authentication prevents unauthorized access

***

## Initial Connection Security

MainWP 5.3 introduced enhanced security features for the site connection process.

> [!NOTE]
>
> MainWP Child requires at least one initial connection authentication method: Password Authentication, Unique Security ID, or both. You cannot disable both methods in MainWP Child settings.

### Password Authentication

MainWP uses the WordPress administrator's password for verification during initial setup. This feature is enabled by default and ensures only verified administrators can authorize connections. It can be disabled only when Unique Security ID remains enabled.

| Aspect | Detail |
| - | - |
| Usage | Verification during initial setup only |
| Storage | Password is never stored on Dashboard or sent to MainWP.com |
| After connection | A per-site key pair authenticates subsequent requests |
| Per-user setting | Each admin controls their own password authentication setting |
| Connection requirement | If Password Authentication is disabled, Unique Security ID must be enabled |

> [!TIP]
>
> Consider creating a dedicated "MainWP Admin" account for connecting sites. This account can be monitored or modified independently.

### Unique Security ID

Unique Security ID can be used as an alternative or additional authentication check during setup. When enabled, this ID must match on both Dashboard and Child Site for the connection to succeed. It is optional only when Password Authentication remains enabled. If Password Authentication is disabled, Unique Security ID is required.

### Connection Timeout

The MainWP Child plugin includes a connection timeout to minimize exposure. After activation, if no connection is established within the specified time (in minutes), the plugin automatically deactivates itself. This prevents idle plugins from remaining accessible.

Set the limit in **Set Connection Timeout** at **WordPress Admin > Settings > MainWP Child > Settings**. The default is 20 minutes. Enter `0` to turn off the timeout.

While the site is not connected, the MainWP Child activation notice in WordPress Admin shows:

* **Site URL** and **Administrator username** fields with **Copy** buttons, so you can paste them into the Dashboard's Add Site form
* A live countdown of the minutes left before MainWP Child deactivates itself

When the countdown reaches zero, MainWP Child deactivates on the next WordPress Admin request unless the site was connected first. Reload the page to check. If the plugin was deactivated, reactivate it from the **Plugins** page to start a new connection window. After reactivation, the notice explains that the plugin switched itself off because no Dashboard connected within the time limit.

> [!NOTE]
>
> The countdown is not shown when the timeout is turned off or when MainWP Child is loaded as a must-use plugin, because the plugin does not deactivate itself in those cases.

### Disconnect Site Option

The Disconnect Site feature allows you to clear all connection data for a Child Site directly from the Dashboard. Use this when:

* Decommissioning sites
* Re-establishing secure connections
* Troubleshooting setup issues

***

## Post-Connection Security

After a site is added, MainWP Dashboard signs requests with that site's private key. MainWP Child verifies the signatures using the public key saved during connection.

### Key Pair Generation

With the default OpenSSL connection method, MainWP Dashboard creates a key pair when it first connects to a child site:

1. MainWP Dashboard generates a 2048-bit RSA public/private key pair using `openssl_pkey_new()`
2. Public key is saved on both the child site and Dashboard
3. Private key is encrypted and saved only on the Dashboard

For connections created before version 5.3, complete the [private-key encryption steps](https://docs.mainwp.com/advanced/openssl-keys-encryption.md) if you have not already done so.

PHPSecLib is an alternative for key generation and signing that you select in the global or per-site [connection settings](https://docs.mainwp.com/advanced/custom-signature-algorithm-and-phpseclib-as-alternative-to-openssl.md).

### Request Signing and Verification

OpenSSL signs requests using SHA-256 by default.

| Step | Function | Description |
| - | - | - |
| Signing | `openssl_sign()` | Dashboard creates cryptographic signature using private key |
| Verification | `openssl_verify()` | Child site verifies signature using public key |

The child site only processes requests with valid signatures that match its stored public key.

### HTTPS Encryption and Certificate Verification

HTTPS encrypts request and response contents in transit. Request signing authenticates requests but does not encrypt an HTTP connection, so use HTTPS URLs for connected child sites.

SSL certificate verification is enabled by default. You can configure it globally or per site. Keep it enabled to verify the child site's certificate.

***

## HTTPS Request Structure

MainWP Dashboard sends requests to each child site's configured URL using cURL. The following example uses HTTPS. Requests include:

| Parameter | Purpose |
| - | - |
| Username | Administrator username used to establish the connection |
| Function | Name of the function to execute on the child site |
| MainWP Signature | Authentication signature for request verification |

### Example Sync Request

```text theme={null}
https://childsite.com/wp-admin/admin-ajax.php?user=demouser&function=stats&mainwpsignature=dgTOIUbQyBWvCh0pNhnwmxmHoeayfg34PCBJxhszRFASTfFwRqrJaMk%2F%2FLJSQvDKlQ8A2Wf4cwowG1PaL9f%2FdG2DzBDucu9GRMi%2Bq18iauk9JgXR%2FaPd9jSvAzoxc5GSJrDmBOLLZEFe8M0VWJ2VVdRm3Bq%2BPyD4p4AtB0%2BphMRXnP99PVMXkwMJKVnf1OT7jjAYATBuSkkccsZ5bRyZDHuJw78L%2BsGhhvKxoz0IwRNqnV4e09LuPW8CKe6DtyPc9SRD9ojc69NQxZBDa2Zyr%2FvH%2BypFvFxsw0Eh0Tnoiq9giVUSDNlEtR7RLJbtGOEKr4%2BBMtmIb1M9ODy72N9%2Ftg%3D%3D
```

If the `mainwpsignature` doesn't match, the child site rejects the request.

***

## Request Parameter Escaping

Before sending any request to a child site, MainWP Dashboard escapes all parameter values to prevent code injection.

For example, the Jump to WP Admin feature escapes `name` and `value` attributes using `esc_attr()`:

![Code showing esc\_attr function usage for escaping request parameters](https://mintcdn.com/mainwp/OKpZbeo5_cAajLyl/images/miscellaneous/advanced-miscellaneous-624352.jpg?fit=max\&auto=format\&n=OKpZbeo5_cAajLyl\&q=85\&s=647b47d4884f946767ec6b8845a77a2d)

### Why This Matters

This escaping protects against scenarios where an attacker might:

1. Trick you into clicking a crafted link
2. Attempt to pass malicious code through request parameters

Since MainWP escapes all attributes, any potentially harmful code becomes harmless before reaching the child site.

***

## Complete Request Flow

The security system works as follows:

1. **Preparation**: Dashboard escapes all request attributes
2. **Transmission**: HTTPS request sent with MainWP Signature and parameters
3. **Verification**: Child site validates signature against stored public key
4. **Execution**: Only authenticated requests are processed

***

## Related Resources

* [MainWP Security](https://docs.mainwp.com/getting-started/how-secure-is-the-mainwp-plugin.md) - Security overview
* [OpenSSL Key Encryption](https://docs.mainwp.com/advanced/openssl-keys-encryption.md) - Private key encryption
* [API Key Storage](https://docs.mainwp.com/advanced/security/how-mainwp-stores-3rd-party-api-keys-and-other-sensitive-data.md) - Credential encryption
* [Two-Factor Authentication](https://docs.mainwp.com/advanced/miscellaneous/how-to-add-two-factor-authentication-2fa-to-mainwp.md) - Additional login security


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.