![]() |
Bearsampp 2026.9.23
|
Public Member Functions | |
| createCrt ($name, $destPath=null) | |
| delSslCertificate () | |
| delSslCertificateHandler ($window, $id, $ctrl, $param1, $param2) | |
| ensureFirefoxTrustPrompt () | |
| existsCrt ($name) | |
| genSslCertificate () | |
| genSslCertificateHandler ($window, $id, $ctrl, $param1, $param2) | |
| getCrts () | |
| isExpired ($name) | |
| makeRootCa () | |
| rebuildAllCerts () | |
| removeCrt ($name, $destPath=null) | |
Private Member Functions | |
| ensureMkcertExeExists () | |
| ensureRootCaExists ($destPath) | |
| ensureSslDirExists () | |
| getFirefoxProfileDirs () | |
| isFirefoxEnterpriseRootsConfigured () | |
| maybePromptTrustRootCa ($rootCaPath, $force) | |
| trustRootCaInFirefox ($rootCaPath) | |
| validateCertificateName ($name) | |
Private Attributes | |
| $firefoxTrustDeclinedFile = 'firefoxTrustDeclined' | |
| $rootCaName = 'BearsamppRootCA' | |
| $trustPromptShownThisRun = false | |
| $wbDelSslBtnCancel | |
| $wbDelSslBtnDelete | |
| $wbDelSslBtnDest | |
| $wbDelSslInputDest | |
| $wbDelSslListCerts | |
| $wbDelSslProgressBar | |
| $wbGenSslBtnCancel | |
| $wbGenSslBtnDest | |
| $wbGenSslBtnSave | |
| $wbGenSslInputDest | |
| $wbGenSslInputName | |
| $wbGenSslProgressBar | |
Class OpenSsl
Provides SSL certificate management for the Bearsampp environment. Generates, removes, and rebuilds SSL certificates using mkcert and configures browser trust for the Bearsampp Root CA.
Definition at line 18 of file class.openssl.php.
| createCrt | ( | $name, | |
| $destPath = null ) |
Creates a certificate with the specified name and destination path.
| string | $name | The name of the certificate. |
| string | null | $destPath | The destination path where the certificate files will be saved. If null, the default SSL path is used. |
Definition at line 218 of file class.openssl.php.
References $result, APP_LOCALHOST, ensureMkcertExeExists(), ensureRootCaExists(), ensureSslDirExists(), Log\error(), Batch\exec(), Path\formatWindowsPath(), Path\getMkcertExe(), Path\getOpenSslExe(), Log\trace(), and validateCertificateName().
Referenced by makeRootCa(), and rebuildAllCerts().
| delSslCertificate | ( | ) |
Displays a WinBinder GUI for deleting an SSL certificate.
Definition at line 533 of file class.openssl.php.
References $bearsamppLang, Lang\BUTTON_BROWSE, Lang\BUTTON_CANCEL, Lang\BUTTON_DELETE, Lang\DELSSL_TITLE, Path\formatWindowsPath(), Path\getSslPath(), Lang\NAME, and Lang\TARGET.
| delSslCertificateHandler | ( | $window, | |
| $id, | |||
| $ctrl, | |||
| $param1, | |||
| $param2 ) |
Handler for the SSL certificate deletion WinBinder GUI.
| mixed | $window | The window object where the event occurred. |
| int | $id | The ID of the event. |
| mixed | $ctrl | The control that triggered the event. |
| mixed | $param1 | The first parameter of the event. |
| mixed | $param2 | The second parameter of the event. |
Definition at line 569 of file class.openssl.php.
References $bearsamppLang, WinBinder\CTRL_ID, WinBinder\CTRL_OBJ, Lang\DELSSL_DELETED, Lang\DELSSL_DELETED_ERROR, Lang\DELSSL_TITLE, Lang\ERROR_FILE_NOT_FOUND, Path\formatUnixPath(), Lang\GENSSL_PATH, and getCrts().
| ensureFirefoxTrustPrompt | ( | ) |
Checks whether the SSL Root CA should be trusted, asking the user if necessary. Called during startup so that an existing (previously untrusted) Root CA can be trusted without having to regenerate it.
Definition at line 341 of file class.openssl.php.
References Path\getMkcertRootCaName(), Path\getSslPath(), and maybePromptTrustRootCa().
|
private |
Ensures that the mkcert executable exists, attempting to download it if missing.
Definition at line 58 of file class.openssl.php.
References Log\error(), and Path\getMkcertExe().
Referenced by createCrt(), ensureRootCaExists(), and makeRootCa().
|
private |
Ensures that the Root CA exists, creating it if necessary.
| string | $destPath | The destination path. |
Definition at line 295 of file class.openssl.php.
References $result, ensureMkcertExeExists(), Log\error(), Batch\exec(), Path\formatWindowsPath(), Path\getMkcertExe(), Path\getMkcertRootCaName(), Log\info(), and maybePromptTrustRootCa().
Referenced by createCrt().
|
private |
Ensures that the SSL directory exists, creating it if necessary.
Definition at line 75 of file class.openssl.php.
References Log\error(), Path\getSslPath(), Log\info(), and Log\warning().
Referenced by createCrt(), getCrts(), and removeCrt().
| existsCrt | ( | $name | ) |
Checks if a certificate with the specified name exists.
| string | $name | The name of the certificate. |
Definition at line 627 of file class.openssl.php.
References Path\getSslPath().
| genSslCertificate | ( | ) |
Displays a WinBinder GUI for generating an SSL certificate.
Definition at line 638 of file class.openssl.php.
References $bearsamppLang, Lang\BUTTON_BROWSE, Lang\BUTTON_CANCEL, Lang\BUTTON_SAVE, Path\formatWindowsPath(), Lang\GENSSL_TITLE, Path\getSslPath(), Lang\NAME, and Lang\TARGET.
| genSslCertificateHandler | ( | $window, | |
| $id, | |||
| $ctrl, | |||
| $param1, | |||
| $param2 ) |
Handler for the SSL certificate generation WinBinder GUI.
| mixed | $window | The window object where the event occurred. |
| int | $id | The ID of the event. |
| mixed | $ctrl | The control that triggered the event. |
| mixed | $param1 | The first parameter of the event. |
| mixed | $param2 | The second parameter of the event. |
Definition at line 674 of file class.openssl.php.
References $bearsamppLang, WinBinder\CTRL_ID, WinBinder\CTRL_OBJ, Path\formatUnixPath(), Lang\GENSSL_CREATED, Lang\GENSSL_CREATED_ERROR, Lang\GENSSL_PATH, and Lang\GENSSL_TITLE.
| getCrts | ( | ) |
Retrieves existing certificates from the SSL directory.
Definition at line 718 of file class.openssl.php.
References ensureSslDirExists().
Referenced by delSslCertificateHandler(), and rebuildAllCerts().
|
private |
Finds the Firefox profile directories that contain a prefs.js file.
Definition at line 428 of file class.openssl.php.
Referenced by isFirefoxEnterpriseRootsConfigured(), and trustRootCaInFirefox().
| isExpired | ( | $name | ) |
Checks if a certificate with the specified name is expired or about to expire.
| string | $name | The name of the certificate. |
Definition at line 742 of file class.openssl.php.
References Log\error(), Path\getSslPath(), Log\trace(), and Log\warning().
|
private |
Checks whether all found Firefox profiles are configured to trust the system root certificates (security.enterprise_roots.enabled).
Definition at line 469 of file class.openssl.php.
References getFirefoxProfileDirs().
Referenced by maybePromptTrustRootCa().
| makeRootCa | ( | ) |
Creates a new Root CA and reinstalls it, then rebuilds all certificates.
Definition at line 118 of file class.openssl.php.
References $result, createCrt(), ensureMkcertExeExists(), Log\error(), Batch\exec(), Path\formatWindowsPath(), Path\getMkcertExe(), Path\getMkcertRootCaName(), Path\getSslPath(), Log\info(), maybePromptTrustRootCa(), and rebuildAllCerts().
|
private |
Asks the user whether to trust the SSL Root CA and, if accepted, configures the browsers to trust it. The prompt is shown at most once per run.
| string | $rootCaPath | The path to the Root CA certificate file. |
| bool | $force | True when a brand new Root CA was just created, false when checking an existing one. |
Definition at line 363 of file class.openssl.php.
References $bearsamppLang, $firefoxTrustDeclinedFile, Path\getSslPath(), Log\info(), isFirefoxEnterpriseRootsConfigured(), Lang\SSL_TRUST_FIREFOX_MSG, Lang\SSL_TRUST_ROOT_CA_DONE, Lang\SSL_TRUST_ROOT_CA_MSG, Lang\SSL_TRUST_ROOT_CA_TITLE, trustRootCaInFirefox(), and Log\warning().
Referenced by ensureFirefoxTrustPrompt(), ensureRootCaExists(), and makeRootCa().
| rebuildAllCerts | ( | ) |
Rebuilds all existing certificates in the SSL directory.
Definition at line 167 of file class.openssl.php.
References createCrt(), Log\error(), getCrts(), and Log\info().
Referenced by makeRootCa().
| removeCrt | ( | $name, | |
| $destPath = null ) |
Removes a certificate with the specified name.
| string | $name | The name of the certificate. |
| string | null | $destPath | The destination path where the certificate files are saved. If null, the default SSL path is used. |
Definition at line 801 of file class.openssl.php.
References ensureSslDirExists(), Log\error(), Log\info(), and Log\warning().
|
private |
Configures all found Firefox profiles to trust the system root certificates, which makes HTTPS sites signed by the Bearsampp Root CA display the secure lock.
| string | $rootCaPath | The path to the Root CA certificate file. |
Definition at line 498 of file class.openssl.php.
References Log\error(), getFirefoxProfileDirs(), and Log\info().
Referenced by maybePromptTrustRootCa().
|
private |
Validates the certificate name to prevent command injection attacks. Requires names to start with alphanumeric character to prevent mkcert flag injection. Uses filesystem-safe whitelist (same as removeCrt) to support existing cert names and prevent CMD metacharacter injection. Allows: alphanumeric, dots, dashes, underscores.
| string | $name | The certificate name to validate. |
Definition at line 193 of file class.openssl.php.
Referenced by createCrt().
|
private |
Definition at line 50 of file class.openssl.php.
Referenced by maybePromptTrustRootCa().
|
private |
Definition at line 46 of file class.openssl.php.
|
private |
Definition at line 48 of file class.openssl.php.
|
private |
Definition at line 44 of file class.openssl.php.
|
private |
Definition at line 42 of file class.openssl.php.
|
private |
Definition at line 38 of file class.openssl.php.
|
private |
Definition at line 36 of file class.openssl.php.
|
private |
Definition at line 34 of file class.openssl.php.
|
private |
Definition at line 40 of file class.openssl.php.
|
private |
Definition at line 31 of file class.openssl.php.
|
private |
Definition at line 25 of file class.openssl.php.
|
private |
Definition at line 29 of file class.openssl.php.
|
private |
Definition at line 23 of file class.openssl.php.
|
private |
Definition at line 21 of file class.openssl.php.
|
private |
Definition at line 27 of file class.openssl.php.