---
slug: "flutter-self-signed-request-without-error-via-http-client"
title: "How to Communicate with a Server Using a Self-Signed Certificate (My Own CA) Without Errors in Flutter's HTTP Client"
description: "When Django uses multiple databases and `ForeignKey` cannot traverse across them — `router.allow_relation` behavior and raw SQL workarounds."
url: "https://www.ytyng.com/en/blog/flutter-self-signed-request-without-error-via-http-client"
publish_date: "2021-03-12T02:02:50Z"
created: "2021-03-12T02:02:50Z"
updated: "2026-05-11T13:21:43.545Z"
categories: ["Flutter"]
keywords: ""
featured_image_url: "https://media.ytyng.com/resize/20230812/e3303ae645224131bfae465d6a6c8c7e.png.webp?width=768"
has_video: false
has_music: false
video_urls: []
music_urls: []
lang: "en"
---

# How to Communicate with a Server Using a Self-Signed Certificate (My Own CA) Without Errors in Flutter's HTTP Client

<p class="default s-code-block hljs scala">Write this somewhere</p>
<pre class="default s-code-block hljs scala"><code><span class="hljs-class"><span class="hljs-keyword">class</span> <span class="hljs-title">DevHttpOverrides</span> <span class="hljs-keyword">extends</span> <span class="hljs-title">HttpOverrides</span> </span>{
  <span class="hljs-meta">@override</span>
  <span class="hljs-type">HttpClient</span> createHttpClient(<span class="hljs-type">SecurityContext</span> context) {
    <span class="hljs-keyword">return</span> <span class="hljs-keyword">super</span>.createHttpClient(context)
      ..badCertificateCallback = (<span class="hljs-type">X509Certificate</span> cert, <span class="hljs-type">String</span> host, int port) =&gt; <span class="hljs-literal">true</span>;
  }
}<br /><br /></code></pre>
<p><code></code></p>
<pre class="default s-code-block hljs ini"><code><span class="hljs-attr">HttpOverrides.global</span> = new DevHttpOverrides()<span class="hljs-comment">;</span></code></pre>
<p><code><span class="hljs-comment">https://stackoverflow.com/questions/59622087/flutter-https-with-self-signed-certificate</span></code></p>
