@capgo/capacitor-ssl-pinning

中文文档
8.1.15发布于 2026/10/15MPL-2.0TypeScriptESM + CJS零依赖构建来源已验证近 30 天下载 3798

Capacitor SSL pinning plugin for Android and iOS that integrates with CapacitorHttp.

原始使用文档
文档目录12 节
  1. ➡️ Get started for free
  2. Key features
  3. Documentation
  4. Compatibility
  5. Install
  6. Configure
  7. Usage
  8. Behavior
  9. API
  10. getConfiguration()
  11. getPluginVersion()
  12. Interfaces

@capgo/capacitor-ssl-pinning

Add SSL certificate pinning to your Capacitor app's native HTTP requests on iOS and Android, so your API traffic only trusts your own certificates.

Capgo - Build Capacitor apps with AI, ship updates instantly

Capgo: push fixes to your Capacitor users in minutes, build signed iOS and Android apps without a Mac, and roll back in one click.

➡️ Get started for free

14-day unlimited free trial. No credit card required

🤖 Building with an AI coding agent? Install Capgo skills so Claude Code, Codex, Cursor, Copilot, or Gemini CLI know how to install and use @capgo/capacitor-ssl-pinning in your Capacitor app: npx skills add Cap-go/capgo-skills. Then ask your agent: "Add @capgo/capacitor-ssl-pinning to my Capacitor app and wire it up." Agent setup guides · Hosted MCP

@capgo/capacitor-ssl-pinning for Capacitor apps

Key features

  • Config only: list certificate files under plugins.SSLPinning.certs in capacitor.config.
  • CapacitorHttp: pinning applies to CapacitorHttp requests when it is enabled and at least one certificate is listed.
  • Sync hook: cap sync copies the certificates and converts PEM files to DER for iOS.
  • Exclusions: excludedDomains lets chosen URLs skip pinning.
  • Inspect: getConfiguration() returns the active native configuration.
  • Platforms: iOS and Android. Not available on web.

Capgo SSL Pinning brings certificate pinning to Capacitor 8 apps by integrating with CapacitorHttp on Android and iOS.

The implementation follows the Ionic SSL pinning install flow and uses the same plugins.SSLPinning configuration shape documented at ionic.io.

Documentation

The most complete doc is available here: https://capgo.app/docs/plugins/ssl-pinning/

Compatibility

Plugin versionCapacitor compatibilityMaintained
v8.*.*v8.*.*✅

Install

You can use our AI-Assisted Setup to install the plugin. Add the Capgo skills to your AI tool using the following command:

npx skills add https://github.com/cap-go/capacitor-skills --skill capacitor-plugins

Then use the following prompt:

Use the `capacitor-plugins` skill from `cap-go/capacitor-skills` to install the `@capgo/capacitor-ssl-pinning` plugin in my project.

If you prefer Manual Setup, install the plugin by running the following commands and follow the platform-specific instructions below:

bun add @capgo/capacitor-ssl-pinning
bunx cap sync

Configure

Enable Capacitor HTTP interception and declare the certificate files relative to your app root:

import type { CapacitorConfig } from '@capacitor/cli';

const config: CapacitorConfig = {
  plugins: {
    CapacitorHttp: {
      enabled: true,
    },
    SSLPinning: {
      certs: ['sslCerts/production/primary.cer', 'sslCerts/production/backup.der'],
      excludedDomains: ['https://analytics.google.com'],
    },
  },
};

export default config;

During bunx cap sync, the plugin copies the configured certificates into webDir/certs, which lets both native implementations load them from the bundled app assets. Both .cer and .der are supported; PEM .cer files are converted to DER automatically for iOS.

Usage

Make HTTPS calls with CapacitorHttp:

import { CapacitorHttp } from '@capacitor/core';

const response = await CapacitorHttp.get({
  url: 'https://api.example.com/health',
});

If the server certificate does not match one of the pinned certificates, the native request fails.

Behavior

  • Android injects a pinned SSLSocketFactory into Capacitor HTTP requests unless the URL matches excludedDomains.
  • iOS swaps the default Capacitor HTTP handler with a pinned URLSession delegate and also answers WebView authentication challenges through the Capacitor plugin hook.
  • Web exposes inspection helpers only; browsers do not support this native pinning behavior.

API

Capacitor API for inspecting SSL pinning configuration.

Native enforcement is applied automatically to CapacitorHttp requests when:

  1. plugins.CapacitorHttp.enabled is true
  2. plugins.SSLPinning.certs contains at least one certificate

getConfiguration()

getConfiguration() => Promise<SSLPinningConfigurationState>

Returns the active native configuration visible to the plugin.

Returns: Promise<SSLPinningConfigurationState>


getPluginVersion()

getPluginVersion() => Promise<PluginVersionResult>

Returns the native implementation version marker.

Returns: Promise<PluginVersionResult>


Interfaces

SSLPinningConfigurationState

Static SSL pinning configuration currently visible to the plugin.

PropTypeDescription
configuredbooleanWhether at least one certificate is configured for native pinning.
certsstring[]Certificate paths from capacitor.config.* relative to the app root.
excludedDomainsstring[]Fully-qualified URLs that should bypass SSL pinning.

PluginVersionResult

Plugin version payload.

PropTypeDescription
versionstringVersion identifier returned by the platform implementation.

版本与发布记录

@capgo/capacitor-ssl-pinning 共发布 15 个版本,首次发布于 2026/03/25;过去 12 个月发布了 15 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
8.1.15latest2026/10/1525 天前
8.1.142026/10/1327 天前
8.1.132026/10/081 个月前
8.1.112026/10/081 个月前
8.1.122026/10/081 个月前
8.1.102026/09/161 个月前

关于 @capgo/capacitor-ssl-pinning 的常见问题

@capgo/capacitor-ssl-pinning 是什么?

Capacitor SSL pinning plugin for Android and iOS that integrates with CapacitorHttp.

如何安装 @capgo/capacitor-ssl-pinning?

在项目目录运行 npm install @capgo/capacitor-ssl-pinning,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@capacitor/core(>=8.0.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@capgo/capacitor-ssl-pinning 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@capgo/capacitor-ssl-pinning 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@capgo/capacitor-ssl-pinning 可以商用吗?

@capgo/capacitor-ssl-pinning 使用 MPL-2.0 许可。弱 Copyleft:可以商用,也可以和闭源代码一起使用;但如果分发时修改了 MPL 授权的文件,这些文件的修改需以 MPL 开源。以上为概括,不构成法律意见,请以许可原文为准。

@capgo/capacitor-ssl-pinning 的下载量有多少?

根据 npm 官方下载统计,@capgo/capacitor-ssl-pinning 在 2026/10/09 – 2026/11/07 这 30 天内被下载 3,798 次,日均约 127 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@capgo/capacitor-ssl-pinning 还在维护吗?

最新版本 8.1.15 发布于 2026/10/15(25 天前);至今共发布 15 个版本,其中过去 12 个月发布了 15 个;首次发布于 2026/03/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。