feat: add option to trust any TLS certificate for IMAP connections

This commit is contained in:
rustmailer
2025-11-27 00:57:43 +08:00
parent 78b33f8994
commit 7c7e353114
33 changed files with 291 additions and 65 deletions
@@ -99,6 +99,7 @@ export type Account = {
use_proxy?: number;
};
enabled: boolean;
use_dangerous: boolean;
date_since?: {
fixed?: string;
relative?: {
@@ -116,6 +117,7 @@ const getAccountSchema = (isEdit: boolean, t: (key: string) => string) =>
email: z.string({ required_error: t('validation.emailRequired') }).email({ message: t('validation.invalidEmail') }),
imap: getImapConfigSchema(isEdit, t),
enabled: z.boolean(),
use_dangerous: z.boolean(),
date_since: getDateSelectionSchema(t).optional(),
folder_limit: z
.number({ invalid_type_error: t('validation.folderLimitMustBeNumber') })
@@ -137,7 +139,7 @@ export type Steps = [
const getSteps = (t: (key: string) => string): Steps => [
{ id: "step-1", name: t('accounts.steps.emailAddress'), fields: ["email"] },
{ id: "step-2", name: t('accounts.steps.imap'), fields: ["imap"] },
{ id: "step-2", name: t('accounts.steps.imap'), fields: ["imap", "use_dangerous"] },
{ id: "step-3", name: t('accounts.steps.syncPreferences'), fields: ["enabled", "date_since", "folder_limit", "sync_interval_min"] },
{ id: "step-4", name: t('accounts.steps.summary'), fields: [] },
];
@@ -164,6 +166,7 @@ const defaultValues: Account = {
use_proxy: undefined
},
enabled: true,
use_dangerous: false,
date_since: undefined,
folder_limit: undefined,
sync_interval_min: 10,
@@ -189,6 +192,7 @@ const mapCurrentRowToFormValues = (currentRow: AccountModel): Account => {
email: currentRow.email,
imap,
enabled: currentRow.enabled,
use_dangerous: currentRow.use_dangerous,
date_since: currentRow.date_since ?? undefined,
folder_limit: currentRow.folder_limit ?? undefined,
sync_interval_min: currentRow.sync_interval_min ?? 10,
@@ -266,6 +270,7 @@ export function AccountActionDialog({ currentRow, open, onOpenChange }: Props) {
},
},
enabled: data.enabled,
use_dangerous: data.use_dangerous,
date_since: data.date_since,
folder_limit: data.folder_limit,
sync_interval_min: data.sync_interval_min,
@@ -147,7 +147,7 @@ export function RunningStateDialog({ currentRow, open, onOpenChange }: Props) {
</span>
) : state.initial_sync_start_time ? (
<span className="flex items-center gap-1 text-blue-600">
{t('runningState.inProgress')}
{t('accounts.runningState.inProgress')}
</span>
) : (
<span className="text-yellow-600">{t('accounts.runningState.notStarted')}</span>
@@ -38,6 +38,7 @@ import { Account } from "./action-dialog";
import { PasswordInput } from "@/components/password-input";
import useProxyList from "@/hooks/use-proxy";
import { useTranslation } from "react-i18next";
import { Checkbox } from "@/components/ui/checkbox";
interface StepProps {
isEdit: boolean;
@@ -110,6 +111,23 @@ export default function Step2({ isEdit }: StepProps) {
</FormItem>
)}
/>
<FormField
control={control}
name="use_dangerous"
render={({ field }) => (
<FormItem className="flex flex-col items-start gap-y-1">
<FormLabel>{t('accounts.useDangerous')}:</FormLabel>
<FormControl>
<Checkbox
className="mt-2"
checked={field.value}
onCheckedChange={field.onChange}
/>
</FormControl>
<FormDescription>{t('accounts.useDangerousDescription')}</FormDescription>
</FormItem>
)}
/>
<FormField
control={control}
name="imap.auth.auth_type"
@@ -93,7 +93,6 @@ export default function Step3() {
</FormItem>
)}
/>
<FormLabel className="flex items-center justify-between">{t('accounts.dateSince')}:</FormLabel>
<RadioGroup
defaultValue={rangeType}
+1
View File
@@ -60,4 +60,5 @@ export interface AccountModel {
created_at: number;
updated_at: number;
use_proxy?: number
use_dangerous: boolean
}
+3 -1
View File
@@ -298,7 +298,9 @@
"enable": "تفعيل",
"disable": "تعطيل",
"thisWillPreventTheAccountFromBeingUsed": "لن يقوم هذا الحساب بمزامنة البيانات من خادم IMAP بعد الآن، ولكن لا تزال البيانات الموجودة متاحة للعرض.",
"disabled": "معطل"
"disabled": "معطل",
"useDangerous": "الثقة بأي شهادة TLS",
"useDangerousDescription": "فعّل هذا الخيار فقط إذا كنت تتصل بخادم IMAP يستخدم شهادة TLS صادرة عن CA عام أو شهادة موقعة ذاتياً قد لا يتعرف عليها نظامك. هذا الإعداد يتجاوز عملية التحقق الاعتيادية من الشهادة، وقد يعرض الاتصال لهجمات “رجل في الوسط” — فعّله فقط إذا كنت تدرك المخاطر."
},
"mailbox": {
"title": "صندوق البريد",
+3 -1
View File
@@ -298,7 +298,9 @@
"enable": "Aktivér",
"disable": "Deaktivér",
"thisWillPreventTheAccountFromBeingUsed": "Denne konto vil ikke længere synkronisere data fra IMAP-serveren, men eksisterende data vil stadig være tilgængelige.",
"disabled": "Deaktiveret"
"disabled": "Deaktiveret",
"useDangerous": "Stol på ethvert TLScertifikat",
"useDangerousDescription": "Aktivér denne indstilling kun hvis du opretter forbindelse til en IMAPserver, der bruger et offentligt CAcertifikat eller et selvsigneret certifikat, som dit system måske ikke genkender. Denne indstilling omgår standard certificeringsvalidering og kan gøre dig sårbar over for maninthemiddleangreb — aktiver kun hvis du forstår risikoen."
},
"mailbox": {
"title": "Mailboks",
+3 -1
View File
@@ -298,7 +298,9 @@
"enable": "Aktivieren",
"disable": "Deaktivieren",
"thisWillPreventTheAccountFromBeingUsed": "Dieses Konto synchronisiert keine Daten mehr vom IMAP-Server, aber vorhandene Daten bleiben weiterhin zugänglich.",
"disabled": "Deaktiviert"
"disabled": "Deaktiviert",
"useDangerous": "Jedem TLSZertifikat vertrauen",
"useDangerousDescription": "Aktivieren Sie diese Option nur, wenn Sie sich mit einem IMAPServer verbinden, der ein öffentliches CAZertifikat oder ein selbstsigniertes Zertifikat verwendet, das Ihr System möglicherweise nicht erkennt. Diese Einstellung umgeht die StandardZertifikatsprüfung und kann Sie für ManintheMiddleAngriffe anfällig machen aktivieren Sie nur, wenn Sie die Risiken verstehen."
},
"mailbox": {
"title": "Postfach",
+3 -1
View File
@@ -298,7 +298,9 @@
"enable": "Enable",
"disable": "Disable",
"thisWillPreventTheAccountFromBeingUsed": "This account will no longer sync data from the IMAP server, but existing data will still be accessible.",
"disabled": "Disabled"
"disabled": "Disabled",
"useDangerous": "Trust Any TLS Certificate",
"useDangerousDescription": "Enable this option only if you are connecting to an IMAP server with a public or self-signed certificate that may not be recognized by your system. Using this setting bypasses standard certificate validation, which can expose you to man-in-the-middle attacks. Only enable if you understand the risks."
},
"mailbox": {
"title": "Mailbox",
+3 -1
View File
@@ -298,7 +298,9 @@
"enable": "Activar",
"disable": "Desactivar",
"thisWillPreventTheAccountFromBeingUsed": "Esta cuenta ya no sincronizará datos desde el servidor IMAP, pero los datos existentes seguirán siendo accesibles.",
"disabled": "Deshabilitado"
"disabled": "Deshabilitado",
"useDangerous": "Confiar en cualquier certificado TLS",
"useDangerousDescription": "Activa esta opción solo si te estás conectando a un servidor IMAP que utiliza un certificado público o autofirmado, el cual puede no ser reconocido por tu sistema. Esta opción omite la validación estándar del certificado y puede exponerte a ataques de tipo “maninthemiddle” — actívala solo si entiendes los riesgos."
},
"mailbox": {
"title": "Buzón",
+3 -1
View File
@@ -298,7 +298,9 @@
"enable": "Ota käyttöön",
"disable": "Poista käytöstä",
"thisWillPreventTheAccountFromBeingUsed": "Tili ei enää synkronoi tietoja IMAP-palvelimelta, mutta olemassa olevat tiedot ovat edelleen käytettävissä.",
"disabled": "Poistettu käytöstä"
"disabled": "Poistettu käytöstä",
"useDangerous": "Luota mihin tahansa TLS-sertifikaattiin",
"useDangerousDescription": "Ota tämä vaihtoehto käyttöön vain, jos IMAP-palvelin käyttää julkista CA:ta tai itse allekirjoitettua sertifikaattia, jonka järjestelmä ei tunnista. Tämä ohittaa normaalin sertifikaattitarkistuksen, ja voi altistaa Man-in-the-Middle -hyökkäyksille. Käytä vain, jos ymmärrät riskin."
},
"mailbox": {
"title": "Sähköposti",
+3 -1
View File
@@ -298,7 +298,9 @@
"enable": "Activer",
"disable": "Désactiver",
"thisWillPreventTheAccountFromBeingUsed": "Ce compte ne synchronisera plus les données depuis le serveur IMAP, mais les données existantes resteront accessibles.",
"disabled": "Désactivé"
"disabled": "Désactivé",
"useDangerous": "Faire confiance à nimporte quel certificat TLS",
"useDangerousDescription": "Activez cette option seulement si vous vous connectez à un serveur IMAP utilisant un certificat public ou autosigné que votre système pourrait ne pas reconnaître. Cette option contourne la vérification standard des certificats, ce qui peut vous exposer à des attaques de type hommedumilieu — nactivez que si vous comprenez les risques."
},
"mailbox": {
"title": "Boîte aux lettres",
+3 -1
View File
@@ -298,7 +298,9 @@
"enable": "Attiva",
"disable": "Disattiva",
"thisWillPreventTheAccountFromBeingUsed": "Questo account non sincronizzerà più i dati dal server IMAP, ma i dati esistenti resteranno accessibili.",
"disabled": "Disabilitato"
"disabled": "Disabilitato",
"useDangerous": "Accetta qualsiasi certificato TLS",
"useDangerousDescription": "Abilita questa opzione solo se ti connetti a un server IMAP che utilizza un certificato pubblico o autofirmato che il tuo sistema potrebbe non riconoscere. Questa impostazione salta la verifica standard del certificato e può esporre la connessione ad attacchi “maninthemiddle” — attivala solo se comprendi i rischi."
},
"mailbox": {
"title": "Posta in arrivo",
+3 -1
View File
@@ -298,7 +298,9 @@
"enable": "有効化",
"disable": "無効化",
"thisWillPreventTheAccountFromBeingUsed": "このアカウントはIMAPサーバーからのデータ同期を行わなくなりますが、既存のデータは引き続き参照可能です。",
"disabled": "無効"
"disabled": "無効",
"useDangerous": "任意の TLS 証明書を信頼する",
"useDangerousDescription": "このオプションを有効にすると、公開 CA または自己署名証明書を使用している IMAP サーバーに対して、システムが証明書を認識していない場合でも接続できます。ただし、標準の証明書検証をバイパスするため、中間者攻撃 (MITM) のリスクがあり — リスクを理解した上でのみ有効にしてください。"
},
"mailbox": {
"title": "メールボックス",
+3 -1
View File
@@ -298,7 +298,9 @@
"enable": "활성화",
"disable": "비활성화",
"thisWillPreventTheAccountFromBeingUsed": "이 계정은 더 이상 IMAP 서버에서 데이터를 동기화하지 않지만, 기존 데이터는 계속 조회할 수 있습니다.",
"disabled": "비활성화"
"disabled": "비활성화",
"useDangerous": "모든 TLS 인증서를 신뢰",
"useDangerousDescription": "공개 CA 인증서 또는 자체 서명 인증서를 사용하는 IMAP 서버에 연결할 때, 시스템에서 인증서를 신뢰하지 않아도 이 옵션을 켜면 무시할 수 있습니다. 하지만 표준 인증서 검증을 무시하기 때문에 중간자 공격에 노출될 수 있습니다 — 위험을 이해한 경우에만 사용하세요"
},
"mailbox": {
"title": "받은 편지함",
+3 -1
View File
@@ -298,7 +298,9 @@
"enable": "Inschakelen",
"disable": "Uitschakelen",
"thisWillPreventTheAccountFromBeingUsed": "Dit account zal geen gegevens meer synchroniseren van de IMAP-server, maar bestaande gegevens blijven toegankelijk.",
"disabled": "Uitgeschakeld"
"disabled": "Uitgeschakeld",
"useDangerous": "Vertrouw elk TLScertificaat",
"useDangerousDescription": "Schakel deze optie alleen in als je verbinding maakt met een IMAPserver die een openbaar CA of een selfsigned certificaat gebruikt dat door je systeem mogelijk niet wordt vertrouwd. Deze instelling omzeilt standaard certificaatverificatie en kan je blootstellen aan maninthemiddleaanvallen — activeer alleen als je de risicos begrijpt."
},
"mailbox": {
"title": "Postvak In",
+3 -1
View File
@@ -298,7 +298,9 @@
"enable": "Aktiver",
"disable": "Deaktiver",
"thisWillPreventTheAccountFromBeingUsed": "Denne kontoen vil ikke lenger synkronisere data fra IMAP-serveren, men eksisterende data vil fortsatt være tilgjengelige.",
"disabled": "Deaktivert"
"disabled": "Deaktivert",
"useDangerous": "Stol på hvilken som helst TLSsertifikat",
"useDangerousDescription": "Aktiver dette alternativet kun hvis IMAPserveren bruker et offentlig CAsertifikat eller et selvsignert sertifikat som systemet ditt ikke gjenkjenner. Innstillingen hopper over vanlig sertifikatvalidering, noe som kan utsette deg for maninthemiddleangrep bruk kun hvis du forstår risikoen."
},
"mailbox": {
"title": "Postkasse",
+3 -1
View File
@@ -298,7 +298,9 @@
"enable": "Ativar",
"disable": "Desativar",
"thisWillPreventTheAccountFromBeingUsed": "Esta conta não sincronizará mais dados do servidor IMAP, mas os dados existentes ainda estarão acessíveis.",
"disabled": "Desativado"
"disabled": "Desativado",
"useDangerous": "Confiar em qualquer certificado TLS",
"useDangerousDescription": "Ative esta opção apenas se estiver a conectar a um servidor IMAP que use um certificado público ou autoassinado que o seu sistema possa não reconhecer. Esta opção ignora a verificação normal de certificados e pode expor a ligação a ataques maninthemiddle — ative apenas se compreender os riscos."
},
"mailbox": {
"title": "Caixa de Entrada",
+3 -1
View File
@@ -298,7 +298,9 @@
"enable": "Включить",
"disable": "Отключить",
"thisWillPreventTheAccountFromBeingUsed": "Этот аккаунт больше не будет синхронизировать данные с IMAP-сервера, но существующие данные останутся доступными.",
"disabled": "Отключено"
"disabled": "Отключено",
"useDangerous": "Доверять любому TLS‑сертификату",
"useDangerousDescription": "Включите этот параметр только если IMAP‑сервер использует публичный CA‑сертификат или самоподписанный сертификат, который система может не распознавать. Это отключает стандартную проверку сертификатов и может подвергнуть соединение атакам «человек‑посередине» — активируйте только если вы понимаете риски."
},
"mailbox": {
"title": "Почтовый ящик",
+3 -1
View File
@@ -298,7 +298,9 @@
"enable": "Aktivera",
"disable": "Inaktivera",
"thisWillPreventTheAccountFromBeingUsed": "Det här kontot kommer inte längre att synkronisera data från IMAP-servern, men befintlig data kommer fortfarande att vara åtkomlig.",
"disabled": "Inaktiverad"
"disabled": "Inaktiverad",
"useDangerous": "Lita på vilken TLScertifikat som helst",
"useDangerousDescription": "Aktivera detta alternativ endast om IMAPservern använder ett offentligt eller självsignerat certifikat som inte är betrott av ditt system. Denna inställning kringgår standardverifiering av certifikat, vilket kan utsätta dig för manimittenattacker — slå på endast om du förstår riskerna."
},
"mailbox": {
"title": "Brevlåda",
+3 -1
View File
@@ -298,7 +298,9 @@
"enable": "啟用",
"disable": "停用",
"thisWillPreventTheAccountFromBeingUsed": "該帳戶將不會繼續從 IMAP 伺服器同步資料,但已有資料仍然可以查詢。",
"disabled": "已停用"
"disabled": "已停用",
"useDangerous": "信任任意 TLS 憑證",
"useDangerousDescription": "僅當你連線的 IMAP 伺服器使用公開根憑證或自簽憑證,且系統無法驗證該憑證時才啟用此選項。本選項會略過標準憑證驗證流程,可能導致中間人攻擊等安全風險 — 請確認你了解並接受這些風險後再啟用。"
},
"mailbox": {
"title": "信箱",
+3 -1
View File
@@ -298,7 +298,9 @@
"enable": "启用",
"disable": "禁用",
"thisWillPreventTheAccountFromBeingUsed": "该账户将不会继续从 IMAP 服务器同步数据,但已有数据仍然可以查询。",
"disabled": "已禁用"
"disabled": "已禁用",
"useDangerous": "信任任意 TLS 证书",
"useDangerousDescription": "如果你连接的 IMAP 服务器使用公开 CA 或者自签证书,而系统不认可该证书时,启用此选项可绕过标准证书校验。但请注意,这样可能使你的连接容易受到中间人攻击 —— 仅当你完全理解风险时才启用。"
},
"mailbox": {
"title": "邮箱",