feat: implement license platform business flows and delivery tooling
Add admin and customer interfaces, orders, signed activation and leases, protected package delivery, keyring verification, migrations, security controls, tests and deployment documentation. Co-Authored-By: Craft Agent <agents-noreply@craft.do>
This commit is contained in:
28
backend/internal/httpapi/activation_public.go
Normal file
28
backend/internal/httpapi/activation_public.go
Normal file
@@ -0,0 +1,28 @@
|
||||
package httpapi
|
||||
|
||||
import (
|
||||
"crypto/x509"
|
||||
"encoding/pem"
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func (a *BusinessAPI) activationPublicKey(c *gin.Context) {
|
||||
key, err := readSigningKey(a.signingPrivateKeyPEM)
|
||||
if err != nil {
|
||||
apiError(c, 503, "signing_unavailable", "签名密钥未配置或无效")
|
||||
return
|
||||
}
|
||||
der, err := x509.MarshalPKIXPublicKey(&key.PublicKey)
|
||||
if err != nil {
|
||||
apiError(c, 500, "internal_error", "服务暂时不可用")
|
||||
return
|
||||
}
|
||||
version := "license-v1"
|
||||
data := gin.H{"algorithm": "ECDSA-P256-SHA256", "signature_encoding": "ASN.1-DER/base64-no-padding", "public_key_pem": string(pem.EncodeToMemory(&pem.Block{Type: "PUBLIC KEY", Bytes: der}))}
|
||||
if a.keyring != nil {
|
||||
version = "license-v2"
|
||||
data["key_id"] = a.keyring.Current
|
||||
}
|
||||
data["certificate_version"] = version
|
||||
c.JSON(200, gin.H{"data": data})
|
||||
}
|
||||
Reference in New Issue
Block a user