Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions mobile/lib/entities/store.entity.dart
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@ class SSLClientCertStoreVal {

const SSLClientCertStoreVal(this.data, this.password);

void save() {
Future<void> save() async {
final b64Str = base64Encode(data);
Store.put(StoreKey.sslClientCertData, b64Str);
await Store.put(StoreKey.sslClientCertData, b64Str);
if (password != null) {
Store.put(StoreKey.sslClientPasswd, password!);
await Store.put(StoreKey.sslClientPasswd, password!);
}
}

Expand All @@ -31,8 +31,8 @@ class SSLClientCertStoreVal {
return SSLClientCertStoreVal(certData, passwd);
}

static void delete() {
Store.delete(StoreKey.sslClientCertData);
Store.delete(StoreKey.sslClientPasswd);
static Future<void> delete() async {
await Store.delete(StoreKey.sslClientCertData);
await Store.delete(StoreKey.sslClientPasswd);
}
}
16 changes: 10 additions & 6 deletions mobile/lib/widgets/settings/ssl_client_cert_settings.dart
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class _SslClientCertSettingsState extends State<SslClientCertSettings> {
width: 15,
),
ElevatedButton(
onPressed: widget.isLoggedIn || !isCertExist ? null : () => removeCert(context),
onPressed: widget.isLoggedIn || !isCertExist ? null : () async => await removeCert(context),
child: Text("remove".tr()),
),
],
Expand All @@ -86,7 +86,11 @@ class _SslClientCertSettingsState extends State<SslClientCertSettings> {
);
}

void storeCert(BuildContext context, Uint8List data, String? password) {
Future<void> storeCert(
BuildContext context,
Uint8List data,
String? password,
) async {
if (password != null && password.isEmpty) {
password = null;
}
Expand All @@ -100,7 +104,7 @@ class _SslClientCertSettingsState extends State<SslClientCertSettings> {
showMessage(context, "client_cert_invalid_msg".tr());
return;
}
cert.save();
await cert.save();
HttpSSLOptions.apply();
setState(
() => isCertExist = true,
Expand All @@ -124,7 +128,7 @@ class _SslClientCertSettingsState extends State<SslClientCertSettings> {
),
actions: [
TextButton(
onPressed: () => {ctx.pop(), storeCert(context, data, password.text)},
onPressed: () async => {ctx.pop(), await storeCert(context, data, password.text)},
child: Text("client_cert_dialog_msg_confirm".tr()),
),
],
Expand All @@ -147,8 +151,8 @@ class _SslClientCertSettingsState extends State<SslClientCertSettings> {
}
}

void removeCert(BuildContext context) {
SSLClientCertStoreVal.delete();
Future<void> removeCert(BuildContext context) async {
await SSLClientCertStoreVal.delete();
HttpSSLOptions.apply();
setState(
() => isCertExist = false,
Expand Down