mirror of
https://github.com/NohamR/RMHook.git
synced 2026-08-27 18:29:42 +00:00
Add configurable client key algorithm
This commit is contained in:
@@ -116,6 +116,7 @@ The config file (`~/Library/Preferences/rmfakecloud.config`) supports the follow
|
||||
| `port` | Number | `443` | Your rmfakecloud server port |
|
||||
| `client_cert` | String | (none) | Path to client certificate file (PEM) for mTLS |
|
||||
| `client_key` | String | (none) | Path to client private key file (PEM) for mTLS |
|
||||
| `key_algorithm` | String | `rsa` | Key algorithm: `rsa`, `ec`, `dsa`, `dh`, or `opaque` |
|
||||
| `ca_cert` | String | (none) | Path to custom CA certificate file (PEM) |
|
||||
| `disable_ssl_verification` | Boolean | `false` | Disable SSL peer verification (not recommended) |
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#import <Foundation/Foundation.h>
|
||||
#include <QtCore/QString>
|
||||
#include <QtNetwork/QSsl>
|
||||
|
||||
extern NSString *gConfiguredHostObjC;
|
||||
extern NSNumber *gConfiguredPortObjC;
|
||||
@@ -8,6 +9,7 @@ extern NSNumber *gConfiguredPort;
|
||||
extern QString gConfiguredClientCertPath;
|
||||
extern QString gConfiguredClientKeyPath;
|
||||
extern QString gConfiguredCACertPath;
|
||||
extern QSsl::KeyAlgorithm gConfiguredKeyAlgorithm;
|
||||
extern bool gDisableSSLVerification;
|
||||
|
||||
void ConfigLoadOrCreate(void);
|
||||
|
||||
@@ -8,6 +8,7 @@ static NSString *const kConfigPortKey = @"port";
|
||||
static NSString *const kConfigClientCertKey = @"client_cert";
|
||||
static NSString *const kConfigClientKeyKey = @"client_key";
|
||||
static NSString *const kConfigCACertKey = @"ca_cert";
|
||||
static NSString *const kConfigKeyAlgorithmKey = @"key_algorithm";
|
||||
static NSString *const kConfigDisableSSLVerifyKey = @"disable_ssl_verification";
|
||||
static NSString *const kDefaultHost = @"example.com";
|
||||
static NSNumber *const kDefaultPort = @(443);
|
||||
@@ -19,6 +20,7 @@ NSNumber *gConfiguredPort = @(443);
|
||||
QString gConfiguredClientCertPath;
|
||||
QString gConfiguredClientKeyPath;
|
||||
QString gConfiguredCACertPath;
|
||||
QSsl::KeyAlgorithm gConfiguredKeyAlgorithm = QSsl::Rsa;
|
||||
bool gDisableSSLVerification = false;
|
||||
|
||||
static NSString *PreferencesDirectory(void) {
|
||||
@@ -111,6 +113,21 @@ void ConfigLoadOrCreate(void) {
|
||||
if ([caPathValue isKindOfClass:[NSString class]] && [caPathValue length]) {
|
||||
gConfiguredCACertPath = QStringFromNSStringSafe(caPathValue);
|
||||
}
|
||||
NSString *keyAlgoValue = configDict[kConfigKeyAlgorithmKey];
|
||||
if ([keyAlgoValue isKindOfClass:[NSString class]] && [keyAlgoValue length]) {
|
||||
NSString *lower = [keyAlgoValue lowercaseString];
|
||||
if ([lower isEqualToString:@"ec"]) {
|
||||
gConfiguredKeyAlgorithm = QSsl::Ec;
|
||||
} else if ([lower isEqualToString:@"dsa"]) {
|
||||
gConfiguredKeyAlgorithm = QSsl::Dsa;
|
||||
} else if ([lower isEqualToString:@"dh"]) {
|
||||
gConfiguredKeyAlgorithm = QSsl::Dh;
|
||||
} else if ([lower isEqualToString:@"opaque"]) {
|
||||
gConfiguredKeyAlgorithm = QSsl::Opaque;
|
||||
} else {
|
||||
gConfiguredKeyAlgorithm = QSsl::Rsa;
|
||||
}
|
||||
}
|
||||
if ([disableSSLValue respondsToSelector:@selector(boolValue)]) {
|
||||
gDisableSSLVerification = [disableSSLValue boolValue];
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ void SSLConfigLoad(void) {
|
||||
|
||||
QFile keyFile(QString::fromUtf8(keyPath.toUtf8()));
|
||||
if (keyFile.open(QIODevice::ReadOnly)) {
|
||||
gClientKey = QSslKey(keyFile.readAll(), QSsl::Rsa, QSsl::Pem, QSsl::PrivateKey);
|
||||
gClientKey = QSslKey(keyFile.readAll(), gConfiguredKeyAlgorithm, QSsl::Pem, QSsl::PrivateKey);
|
||||
keyFile.close();
|
||||
if (gClientKey.isNull()) {
|
||||
NSLogger(@"[RMHook] Failed to parse client key from %s", keyPath.toUtf8().constData());
|
||||
|
||||
Reference in New Issue
Block a user