Skip to content

Commit

Permalink
feat(cert): improve certificate renewal and logging #896
Browse files Browse the repository at this point in the history
  • Loading branch information
0xJacky committed Mar 3, 2025
1 parent 6c7edf5 commit 09aedc1
Show file tree
Hide file tree
Showing 18 changed files with 527 additions and 467 deletions.
27 changes: 13 additions & 14 deletions api/certificate/issue.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,6 @@ func IssueCert(c *gin.Context) {
log := &cert.Logger{}
log.SetCertModel(&certModel)

payload.CertID = certModel.ID

go cert.IssueCert(payload, logChan, errChan)

go handleIssueCertLogChan(ws, log, logChan)
Expand All @@ -115,23 +113,24 @@ func IssueCert(c *gin.Context) {
logger.Error(err)
return
}
return
return
}

cert := query.Cert

_, err = cert.Where(cert.Name.Eq(name), cert.Filename.Eq(name), cert.KeyType.Eq(string(payload.KeyType))).
Assign(field.Attrs(&model.Cert{
Domains: payload.ServerName,
SSLCertificatePath: payload.GetCertificatePath(),
SSLCertificateKeyPath: payload.GetCertificateKeyPath(),
AutoCert: model.AutoCertEnabled,
ChallengeMethod: payload.ChallengeMethod,
DnsCredentialID: payload.DNSCredentialID,
Resource: payload.Resource,
MustStaple: payload.MustStaple,
LegoDisableCNAMESupport: payload.LegoDisableCNAMESupport,
})).FirstOrCreate()
Assign(field.Attrs(&model.Cert{
Domains: payload.ServerName,
SSLCertificatePath: payload.GetCertificatePath(),
SSLCertificateKeyPath: payload.GetCertificateKeyPath(),
AutoCert: model.AutoCertEnabled,
ChallengeMethod: payload.ChallengeMethod,
DnsCredentialID: payload.DNSCredentialID,
Resource: payload.Resource,
MustStaple: payload.MustStaple,
LegoDisableCNAMESupport: payload.LegoDisableCNAMESupport,
Log: log.ToString(),
})).FirstOrCreate()
if err != nil {
logger.Error(err)
_ = ws.WriteJSON(IssueCertResponse{
Expand Down
6 changes: 3 additions & 3 deletions app/src/components/Notification/detailRender.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ export function detailRender(args: CustomRender) {
<div>
<div class="mb-2">
{
notifications[args.record.title].content(args.record.details)
notifications[args.record.title]?.content(args.record.details)
|| args.record.content || args.record.details
}
</div>
{args.record.type !== NotificationTypeT.Success && (
{args.record.details?.response && args.record.type !== NotificationTypeT.Success && (
<div>
{ JSON.stringify(args.record.details.response) }
</div>
)}
</div>
)
}
// eslint-disable-next-line sonarjs/no-ignored-exceptions,unused-imports/no-unused-vars
catch (e) {

Check failure on line 23 in app/src/components/Notification/detailRender.tsx

View workflow job for this annotation

GitHub Actions / build_app

Handle this exception or don't catch it at all

Check warning on line 23 in app/src/components/Notification/detailRender.tsx

View workflow job for this annotation

GitHub Actions / build_app

'e' is defined but never used
return args.text
}
Expand Down
79 changes: 42 additions & 37 deletions app/src/language/ar/app.po
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ msgstr "أضف مفتاح مرور"
msgid "Add Configuration"
msgstr "إضافة تكوين"

#: src/views/site/ngx_conf/directive/DirectiveAdd.vue:117
#: src/views/site/ngx_conf/directive/DirectiveAdd.vue:119
msgid "Add Directive Below"
msgstr "أضف التوجيه أدناه"

Expand Down Expand Up @@ -107,7 +107,7 @@ msgid "All"
msgstr "الكل"

#: src/components/Notification/notifications.ts:121
#: src/language/constants.ts:57
#: src/language/constants.ts:58
msgid "All Recovery Codes Have Been Used"
msgstr ""

Expand Down Expand Up @@ -381,6 +381,11 @@ msgstr "خطأ في مزامنة الشهادة"
msgid "Certificate Renewal Interval"
msgstr "الفاصل الزمني لتجديد الشهادة"

#: src/language/constants.ts:21
#, fuzzy
msgid "Certificate renewed successfully"
msgstr "تم المسح بنجاح"

#: src/views/certificate/CertificateEditor.vue:128
#: src/views/site/cert/Cert.vue:33
msgid "Certificate Status"
Expand Down Expand Up @@ -640,11 +645,11 @@ msgstr "حذف"
msgid "Delete Permanently"
msgstr "حذف نهائي"

#: src/components/Notification/notifications.ts:37 src/language/constants.ts:49
#: src/components/Notification/notifications.ts:37 src/language/constants.ts:50
msgid "Delete Remote Site Error"
msgstr "خطأ حذف الموقع البعيد"

#: src/components/Notification/notifications.ts:41 src/language/constants.ts:48
#: src/components/Notification/notifications.ts:41 src/language/constants.ts:49
msgid "Delete Remote Site Success"
msgstr "نجح حذف الموقع البعيد"

Expand Down Expand Up @@ -740,11 +745,11 @@ msgstr "تعطيل"
msgid "Disable auto-renewal failed for %{name}"
msgstr "فشل تعطيل التجديد التلقائي لـ {name}%"

#: src/components/Notification/notifications.ts:45 src/language/constants.ts:51
#: src/components/Notification/notifications.ts:45 src/language/constants.ts:52
msgid "Disable Remote Site Error"
msgstr "خطأ في تعطيل الموقع البعيد"

#: src/components/Notification/notifications.ts:49 src/language/constants.ts:50
#: src/components/Notification/notifications.ts:49 src/language/constants.ts:51
msgid "Disable Remote Site Success"
msgstr "تعطيل الموقع البعيد بنجاح"

Expand Down Expand Up @@ -871,11 +876,11 @@ msgstr "تم إنشاء تكوين النطاق بنجاح"
msgid "Domains list is empty, try to reopen Auto Cert for %{config}"
msgstr "قائمة النطاقات فارغة، حاول إعادة فتح Auto Cert لـ %{config}"

#: src/language/constants.ts:26
#: src/language/constants.ts:27
msgid "Download latest release error"
msgstr "خطأ في تنزيل الإصدار الأخير"

#: src/language/constants.ts:25
#: src/language/constants.ts:26
msgid "Downloading latest release"
msgstr "تنزيل الإصدار الأحدث"

Expand Down Expand Up @@ -950,11 +955,11 @@ msgstr "فشل تفعيل التجديد التلقائي لـ %{name}"
msgid "Enable failed"
msgstr "فشل التفعيل"

#: src/components/Notification/notifications.ts:53 src/language/constants.ts:53
#: src/components/Notification/notifications.ts:53 src/language/constants.ts:54
msgid "Enable Remote Site Error"
msgstr "خطأ في تفعيل الموقع البعيد"

#: src/components/Notification/notifications.ts:57 src/language/constants.ts:52
#: src/components/Notification/notifications.ts:57 src/language/constants.ts:53
msgid "Enable Remote Site Success"
msgstr "نجح تفعيل الموقع البعيد"

Expand Down Expand Up @@ -1020,7 +1025,7 @@ msgstr "تم التفعيل بنجاح"
msgid "Encrypt website with Let's Encrypt"
msgstr "تشفير الموقع باستخدام Let's Encrypt"

#: src/language/constants.ts:21
#: src/language/constants.ts:22
msgid "Environment variables cleaned"
msgstr "تم تنظيف متغيرات البيئة"

Expand Down Expand Up @@ -1096,7 +1101,7 @@ msgstr "فشل في التفعيل %{msg}"
msgid "Failed to save, syntax error(s) was detected in the configuration."
msgstr "فشل في الحفظ، تم اكتشاف خطأ(أخطاء) في بناء الجملة في التكوين."

#: src/language/constants.ts:31
#: src/language/constants.ts:32
msgid "File exists"
msgstr "الملف موجود"

Expand Down Expand Up @@ -1252,11 +1257,11 @@ msgstr "استيراد شهادة"
msgid "Info"
msgstr "معلومات"

#: src/language/constants.ts:24
#: src/language/constants.ts:25
msgid "Initial core upgrader error"
msgstr "خطأ في ترقية النواة الأولية"

#: src/language/constants.ts:23
#: src/language/constants.ts:24
msgid "Initialing core upgrader"
msgstr "بدء ترقية النواة"

Expand Down Expand Up @@ -1426,7 +1431,7 @@ msgstr "أماكن"
msgid "Log"
msgstr "سجل"

#: src/routes/index.ts:318 src/views/other/Login.vue:223
#: src/routes/index.ts:318 src/views/other/Login.vue:222
msgid "Login"
msgstr "تسجيل الدخول"

Expand Down Expand Up @@ -1787,7 +1792,7 @@ msgstr "متصل"
msgid "OpenAI"
msgstr "أوبن أي آي"

#: src/components/TwoFA/Authorization.vue:100 src/views/other/Login.vue:232
#: src/components/TwoFA/Authorization.vue:100 src/views/other/Login.vue:231
msgid "Or"
msgstr "أو"

Expand Down Expand Up @@ -1873,11 +1878,11 @@ msgstr ""
msgid "Perform"
msgstr "نفذ"

#: src/language/constants.ts:28
#: src/language/constants.ts:29
msgid "Perform core upgrade error"
msgstr "خطأ في تنفيذ ترقية النواة"

#: src/language/constants.ts:27
#: src/language/constants.ts:28
msgid "Performing core upgrade"
msgstr "تنفيذ ترقية النواة"

Expand Down Expand Up @@ -1915,7 +1920,7 @@ msgstr ""
"أحد بيانات الاعتماد أدناه لطلب API لمزود DNS."

#: src/components/Notification/notifications.ts:122
#: src/language/constants.ts:58
#: src/language/constants.ts:59
msgid ""
"Please generate new recovery codes in the preferences immediately to prevent "
"lockout."
Expand Down Expand Up @@ -2133,19 +2138,19 @@ msgstr "تم إعادة تسمية %{orig_path} إلى %{new_path} على %{env_
msgid "Rename %{orig_path} to %{new_path} on %{env_name} successfully"
msgstr "تم إعادة تسمية %{orig_path} إلى %{new_path} على %{env_name} بنجاح"

#: src/components/Notification/notifications.ts:27 src/language/constants.ts:41
#: src/components/Notification/notifications.ts:27 src/language/constants.ts:42
msgid "Rename Remote Config Error"
msgstr "خطأ في إعادة تسمية التكوين البعيد"

#: src/components/Notification/notifications.ts:31 src/language/constants.ts:40
#: src/components/Notification/notifications.ts:31 src/language/constants.ts:41
msgid "Rename Remote Config Success"
msgstr "إعادة تسمية تكوين البعيد بنجاح"

#: src/components/Notification/notifications.ts:61 src/language/constants.ts:55
#: src/components/Notification/notifications.ts:61 src/language/constants.ts:56
msgid "Rename Remote Site Error"
msgstr "خطأ في إعادة تسمية الموقع البعيد"

#: src/components/Notification/notifications.ts:65 src/language/constants.ts:54
#: src/components/Notification/notifications.ts:65 src/language/constants.ts:55
msgid "Rename Remote Site Success"
msgstr "تم إعادة تسمية الموقع البعيد بنجاح"

Expand Down Expand Up @@ -2194,11 +2199,11 @@ msgstr "تمت إعادة التسمية بنجاح"
msgid "Renew Certificate"
msgstr "تجديد الشهادة"

#: src/language/constants.ts:35
#: src/language/constants.ts:36
msgid "Renew Certificate Error"
msgstr "خطأ في تجديد الشهادة"

#: src/language/constants.ts:34
#: src/language/constants.ts:35
msgid "Renew Certificate Success"
msgstr "تجديد الشهادة بنجاح"

Expand All @@ -2211,7 +2216,7 @@ msgstr "تم التجديد بنجاح"
msgid "Request timeout"
msgstr ""

#: src/language/constants.ts:32
#: src/language/constants.ts:33
msgid "Requested with wrong parameters"
msgstr "تم الطلب باستخدام عوامل خاطئة"

Expand Down Expand Up @@ -2267,7 +2272,7 @@ msgstr "يعمل"
msgid "Save"
msgstr "حفظ"

#: src/views/site/ngx_conf/directive/DirectiveAdd.vue:127
#: src/views/site/ngx_conf/directive/DirectiveAdd.vue:129
msgid "Save Directive"
msgstr "حفظ التوجيه"

Expand All @@ -2277,11 +2282,11 @@ msgstr "حفظ التوجيه"
msgid "Save error %{msg}"
msgstr "خطأ في الحفظ %{msg}"

#: src/components/Notification/notifications.ts:69 src/language/constants.ts:47
#: src/components/Notification/notifications.ts:69 src/language/constants.ts:48
msgid "Save Remote Site Error"
msgstr "خطأ في حفظ الموقع البعيد"

#: src/components/Notification/notifications.ts:73 src/language/constants.ts:46
#: src/components/Notification/notifications.ts:73 src/language/constants.ts:47
msgid "Save Remote Site Success"
msgstr "حفظ الموقع البعيد بنجاح"

Expand Down Expand Up @@ -2411,7 +2416,7 @@ msgstr ""
msgid "Show"
msgstr "عرض"

#: src/views/other/Login.vue:241
#: src/views/other/Login.vue:240
msgid "Sign in with a passkey"
msgstr "تسجيل الدخول باستخدام مفتاح المرور"

Expand Down Expand Up @@ -2472,7 +2477,7 @@ msgstr "مسار مفتاح شهادة SSL"
msgid "SSL Certificate Path"
msgstr "مسار شهادة SSL"

#: src/views/other/Login.vue:198
#: src/views/other/Login.vue:197
msgid "SSO Login"
msgstr "تسجيل الدخول عبر SSO"

Expand Down Expand Up @@ -2566,11 +2571,11 @@ msgstr "نجح مزامنة الشهادة %{cert_name} إلى %{env_name}"
msgid "Sync Certificate %{cert_name} to %{env_name} successfully"
msgstr "نجح مزامنة الشهادة %{cert_name} إلى %{env_name}"

#: src/components/Notification/notifications.ts:9 src/language/constants.ts:38
#: src/components/Notification/notifications.ts:9 src/language/constants.ts:39
msgid "Sync Certificate Error"
msgstr "خطأ في مزامنة الشهادة"

#: src/components/Notification/notifications.ts:13 src/language/constants.ts:37
#: src/components/Notification/notifications.ts:13 src/language/constants.ts:38
msgid "Sync Certificate Success"
msgstr "تمت مزامنة الشهادة بنجاح"

Expand All @@ -2584,11 +2589,11 @@ msgstr "تمت مزامنة التكوين %{config_name} إلى %{env_name} ب
msgid "Sync config %{config_name} to %{env_name} successfully"
msgstr "تمت مزامنة التكوين %{config_name} إلى %{env_name} بنجاح"

#: src/components/Notification/notifications.ts:19 src/language/constants.ts:44
#: src/components/Notification/notifications.ts:19 src/language/constants.ts:45
msgid "Sync Config Error"
msgstr "خطأ في تزامن التكوين"

#: src/components/Notification/notifications.ts:23 src/language/constants.ts:43
#: src/components/Notification/notifications.ts:23 src/language/constants.ts:44
msgid "Sync Config Success"
msgstr "تمت مزامنة التكوين بنجاح"

Expand Down Expand Up @@ -2898,7 +2903,7 @@ msgstr "ترقية"
msgid "Upgraded Nginx UI on %{node} successfully 🎉"
msgstr "تمت ترقية Nginx UI على %{node} بنجاح 🎉"

#: src/language/constants.ts:29
#: src/language/constants.ts:30
msgid "Upgraded successfully"
msgstr "تم الترقية بنجاح"

Expand Down Expand Up @@ -2962,7 +2967,7 @@ msgstr "إصدار"
msgid "View"
msgstr "عرض"

#: src/components/Notification/Notification.vue:202
#: src/components/Notification/Notification.vue:203
msgid "View all notifications"
msgstr "عرض جميع التنبيهات"

Expand Down
1 change: 1 addition & 0 deletions app/src/language/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const msg = [
$gettext('Reloading nginx'),
$gettext('Finished'),
$gettext('Issued certificate successfully'),
$gettext('Certificate renewed successfully'),
$gettext('Environment variables cleaned'),

$gettext('Initialing core upgrader'),
Expand Down
Loading

0 comments on commit 09aedc1

Please sign in to comment.