You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何为Kin Marketplace JWT集成创建密钥及ES256签名椭圆曲线PEM密钥

Hey there! Let's walk through everything you need to get your app integrated with Kin Marketplace using ES256-signed JWTs. I'll cover generating valid PEM-format elliptic curve keys, creating compliant tokens, and submitting your key to the Kin ecosystem step by step.

1. Creating PEM-Format Elliptic Curve (EC) Keys for ES256

ES256 relies on the NIST P-256 (prime256v1) elliptic curve. You can generate the required key pair using OpenSSL, which is pre-installed on most systems:

  • Generate a PEM-formatted private key:
    openssl ecparam -name prime256v1 -genkey -noout -out ec-private-key.pem
    
  • Extract the corresponding public key (also PEM-formatted) from the private key:
    openssl ec -in ec-private-key.pem -pubout -out ec-public-key.pem
    

You can open these files in a text editor to verify they start with -----BEGIN PRIVATE KEY----- (for the private key) and -----BEGIN PUBLIC KEY----- (for the public key).

2. Generating ES256-Signed JWTs for Kin Marketplace

To create valid JWTs, use a trusted JWT library for your programming language. Below is an example using Node.js's jsonwebtoken library:

First, install the library:

npm install jsonwebtoken

Then, write code to sign the JWT with your private key:

const jwt = require('jsonwebtoken');
const fs = require('fs');

// Load your PEM private key from a secure location (never hardcode this!)
const privateKey = fs.readFileSync('ec-private-key.pem', 'utf8');

// Build the payload per Kin Marketplace's requirements
const jwtPayload = {
  iss: 'your-app-client-id', // Your app's unique identifier from Kin's dashboard
  sub: 'user-unique-id', // Unique ID for the end user in your system
  aud: 'kin-marketplace-audience', // Kin's specified audience value (check their docs)
  exp: Math.floor(Date.now() / 1000) + 3600, // Token expires in 1 hour (adjust as needed)
  // Add any additional required claims Kin specifies (e.g., scopes)
};

// Sign the JWT with ES256 algorithm
const signedToken = jwt.sign(jwtPayload, privateKey, { algorithm: 'ES256' });

console.log('ES256-Signed JWT:', signedToken);

Important: Double-check that all payload fields match Kin's exact requirements—incorrect claims will cause validation failures.

3. Submitting Your Public Key to the Kin Ecosystem

Once you have your PEM public key, submit it to Kin's system to enable JWT validation:

  • Log into your Kin Developer Dashboard and navigate to your app project.
  • Locate the JWT integration settings section (usually under "Security" or "Authentication").
  • Select "Add Public Key" and either upload your ec-public-key.pem file or paste the full PEM content (including the -----BEGIN PUBLIC KEY----- and -----END PUBLIC KEY----- lines).
  • Save the configuration. Kin's system will automatically validate the key format and curve type.
  • Test your setup: Generate a signed JWT and send it to Kin's test endpoint (if provided) to confirm it passes signature validation.
4. Key Best Practices for Kin Integration
  • Never expose your private key: Store it in a secure secrets manager (like AWS KMS, HashiCorp Vault) or environment variables—never commit it to version control.
  • Rotate keys regularly: Kin supports multiple active public keys, so you can generate new key pairs periodically, upload the new public key, then switch your app to use the new private key.
  • Validate incoming JWTs: When Kin sends JWTs back to your app, use Kin's public key to verify the signature and ensure the request is legitimate.

内容的提问来源于stack exchange,提问作者Doody P

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 03:36:00