junjiechen0/njust/https-server
Claude Code and agent skill by junjiechen0/njust
Trust tier 2
- community
- ext:[{"type":"config","description":"Configuration overrides"}]
Source check pending
Checking that the SKILL.md file is still in the repository.
Install
npx vskill@latest install junjiechen0/njust/https-serverSemi-extensibleMentions customization, but needs skill-specific knowledge. Read the extensible skills standard
SKILL.md
The same SKILL.md was published earlier as junjiechen0/njust/https-server.
仓颉语言 HTTPS 服务端编程 Skill
1. 概述
- HTTPS = HTTP + TLS,在 HTTP 服务端基础上添加 TLS 加密层
- 依赖
stdx.net.http和stdx.net.tls,关于扩展标准库stdx的配置用法,请参阅cangjie-stdxSkill - 核心流程:加载证书/私钥 → 配置
TlsServerConfig→ 传入ServerBuilder.tlsConfig()→ 启动 HTTPS 服务
2. 快速入门
3. TlsServerConfig 配置详解
3.1 构造函数
必须提供服务端证书链和对应私钥。
3.2 完整配置属性
| 属性 | 类型 | 默认值 | 说明 | |
|---|---|---|---|---|
supportedAlpnProtocols | Array<String> | [] | 支持的 ALPN 协议(设置 ["h2"] 启用 HTTP/2) | |
clientIdentityRequired | TlsClientIdentificationMode | Disabled | 客户端证书认证模式 | |
verifyMode | CertificateVerifyMode | Default | 证书验证模式(双向认证时验证客户端证书) | |
cipherSuitesV1_2 | ?Array<CipherSuite> | None | TLS 1.2 密码套件 | |
cipherSuitesV1_3 | ?Array<CipherSuite> | None | TLS 1.3 密码套件 | |
minVersion | TlsVersion | V1_2 | 最低 TLS 版本 | |
maxVersion | TlsVersion | V1_3 | 最高 TLS 版本 | |
securityLevel | Int32 | 2 | 安全级别(0-5) | |
dhParameters | ?DhParameters | None | DH 密钥交换参数 |
3.3 证书验证模式(CertificateVerifyMode)
| 模式 | 说明 | 适用场景 | |
|---|---|---|---|
Default | 使用系统 CA 验证 | 验证客户端证书(默认) | |
CustomCA(certs) | 使用自定义 CA 列表验证 | 自签名客户端证书 | |
TrustAll | 信任所有证书 | 仅限开发测试 |
3.4 客户端认证模式(TlsClientIdentificationMode)
| 模式 | 说明 | |
|---|---|---|
Disabled | 不要求客户端证书(单向认证,默认) | |
Optional | 客户端可选提供证书 | |
Required | 客户端必须提供证书(双向认证/mTLS) |
4. 启用 HTTP/2
HTTP/2 需要 TLS + ALPN h2 配置。如果握手失败,自动回退 HTTP/1.1。
说明:使用["http/1.1"]仅启用 HTTPS 而不启用 HTTP/2。不支持通过Upgrade: h2c从 HTTP/1.1 升级到 HTTP/2。
5. 证书热更新
运行时无需重启服务即可更新 TLS 证书,更新后新建连接将使用新证书:
5.1 Server 证书热更新接口
| 方法 | 签名 | 说明 | |
|---|---|---|---|
updateCert | updateCert(String, String): Unit | 通过文件路径更新证书和私钥 | |
updateCert | updateCert(Array<X509Certificate>, PrivateKey): Unit | 通过对象更新证书和私钥 | |
updateCA | updateCA(String): Unit | 通过文件路径更新 CA 证书 | |
updateCA | updateCA(Array<X509Certificate>): Unit | 通过对象更新 CA 证书 |
6. 双向 TLS 认证(mTLS)
双向认证要求客户端也提供证书,服务端验证客户端身份:
7. HTTP/2 Server Push
仅用于 HTTP/2 协议(需 TLS + ALPN h2),允许服务端主动推送关联资源给客户端:
8. 高级 TLS 配置
8.1 限制 TLS 版本
8.2 完整网络配置(TLS + TCP)
9. 异常类型
| 异常 | 说明 | |
|---|---|---|
TlsException | TLS 握手或通信异常(证书无效、OpenSSL 未安装等) | |
HttpException | HTTP 通用异常 | |
ConnectionException | TCP 连接异常 |
注意:如果未安装 OpenSSL 3 或安装了低版本,运行时会抛出TlsException: Can not load openssl library or function xxx。
10. 关键规则速查
| 规则 | 说明 | |
|---|---|---|
| 证书加载 | X509Certificate.decodeFromPem(pemString) 和 PrivateKey.decodeFromPem(keyString) | |
| 启用 HTTPS | ServerBuilder().tlsConfig(tlsConfig) | |
| 启用 HTTP/2 | tlsConfig.supportedAlpnProtocols = ["h2"];握手失败自动回退 HTTP/1.1 | |
| 仅 HTTPS | tlsConfig.supportedAlpnProtocols = ["http/1.1"] | |
| 证书热更新 | server.updateCert(certPath, keyPath) / server.updateCA(caPath) | |
| 双向认证 | tlsConfig.clientIdentityRequired = Required + tlsConfig.verifyMode = CustomCA(caCerts) | |
| 获取客户端证书 | Handler 中通过 ctx.clientCertificate 获取 | |
| Server Push | HttpResponsePusher.getPusher(ctx) 获取推送器,仅 HTTP/2 可用 | |
| TLS 版本限制 | tlsConfig.minVersion / tlsConfig.maxVersion | |
| OpenSSL 依赖 | 需安装 OpenSSL 3,详见 cangjie-tls Skill |
Security
- Security scanPassed, 96 of 100Pattern checks on the skill's files.
- Model reviewNot runA model review is scheduled for the next rescan.
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryChecking.njust-ai/skills/cangjie-network/https_server/SKILL.md
Popularity
- 7-day trend score
- 0
Not refreshed yet.
Extension points
configConfiguration overrides
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/junjiechen0/njust/https-server)