发布新帖

查找

文章
· 一月 27 阅读大约需 3 分钟

在无法访问系统 x509 证书/密钥的情况下生成 JWT

如果要从 x509 证书/密钥生成JWT,对%SYS.X509Credentials的任何操作(包括读取)都需要 %Admin_Secure 资源上的 U。之所以需要 %Admin_Secure,是因为 %SYS.X509Credentials 是持久的,这样做是为了防止所有用户访问私钥。

如果 %Admin_Secure 资源在运行时不可用,可以使用以下变通方法。

在查看 JWT 生成代码时,我发现 JWT 代码仅利用 %SYS.X509Credentials 作为 PrivateKeyPrivateKeyPasswordCertificate 的运行时数据源。作为一种变通方法,您可以使用 X.509 接口的运行时非持久化实现,只公开这些属性。如果要使用互操作性,证书/PK 可以存储在凭证中,以便安全访问:

Class User.X509 Extends %RegisteredObject
{

Property PrivateKey As %VarString;
Property PrivateKeyPassword As %String;
Property Certificate As %VarString;
Property HasPrivateKey As %Boolean [ InitialExpression = {$$$YES} ];
ClassMethod GetX509() As User.X509
{
    set x509 = ..%New()
    set x509.PrivateKey = ..Key()
    set x509.Certificate = ..Cert()
    quit x509
}

/// Get X509 object from credential.
/// Username is a Cert, Password is a Private Key
ClassMethod GetX509FromCredential(credential) As User.X509
{
    set credentialObj = ##class(Ens.Config.Credentials).%OpenId(credential,,.sc)
    throw:$$$ISERR(sc) ##class(%Exception.StatusException).ThrowIfInterrupt(sc)
    
    set x509 = ..%New()
    set x509.PrivateKey = credentialObj.Password
    set x509.Certificate = credentialObj.Username
    quit x509
}

ClassMethod Key()
{
    q "-----BEGIN RSA PRIVATE KEY-----"_$C(13,10)
    _"YOUR_TEST_KEY"_$C(13,10)
    _"-----END RSA PRIVATE KEY-----"
}

ClassMethod Cert() As %VarString
{
    q "-----BEGIN CERTIFICATE-----"_$C(13,10)
    _"YOUR_TEST_CERT"_$C(13,10)
    _"-----END CERTIFICATE-----"
}

}

您还可以通过以下方式生成 JWT:

ClassMethod JWT() As %Status
{
    Set sc = $$$OK
    //Set x509 = ##class(%SYS.X509Credentials).GetByAlias("TempKeyPair")
    Set x509 = ##class(User.X509).GetX509()
    
    Set algorithm ="RS256"
    Set header = {"alg": (algorithm), "typ": "JWT"}
    Set claims= {"Key": "Value" }
    
    #; create JWK
    Set sc = ##class(%Net.JSON.JWK).CreateX509(algorithm,x509,.privateJWK)
    
    If $$$ISERR(sc) {
        Write $SYSTEM.OBJ.DisplayError(sc)
    }

    #; Create JWKS
    Set sc = ##class(%Net.JSON.JWKS).PutJWK(privateJWK,.privateJWKS)
    
    If $$$ISERR(sc) {
        Write $SYSTEM.OBJ.DisplayError(sc)
    }

    Set sc = ##Class(%Net.JSON.JWT).Create(header,,claims,privateJWKS,,.pJWT)
    
    If $$$ISERR(sc) {
        Write $SYSTEM.OBJ.DisplayError(sc)
    }
    
    Write pJWT
	Return sc
}

或者,您也可以使用动态对象来跳过类的创建,在这种情况下,它将看起来像这样:

ClassMethod JWT(credential) As %Status
{
    Set sc = $$$OK
    //Set x509 = ##class(%SYS.X509Credentials).GetByAlias("TempKeyPair")
    Set credentialObj = ##class(Ens.Config.Credentials).%OpenId(credential,,.sc)
    throw:$$$ISERR(sc) ##class(%Exception.StatusException).ThrowIfInterrupt(sc)
    
    Set x509 = {
        "HasPrivateKey": true,
        "PrivateKey": (credentialObj.Password),
        "PrivateKeyPassword":"",
        "Certificate":(credentialObj.Username)
    }

    Set algorithm ="RS256"
    Set header = {"alg": (algorithm), "typ": "JWT"}
    Set claims= {"Key": "Value" }
    
    #; create JWK
    Set sc = ##class(%Net.JSON.JWK).CreateX509(algorithm,x509,.privateJWK)
    
    If $$$ISERR(sc) {
        Write $SYSTEM.OBJ.DisplayError(sc)
    }

    #; Create JWKS
    Set sc = ##class(%Net.JSON.JWKS).PutJWK(privateJWK,.privateJWKS)
    
    If $$$ISERR(sc) {
        Write $SYSTEM.OBJ.DisplayError(sc)
    }

    Set sc = ##Class(%Net.JSON.JWT).Create(header,,claims,privateJWKS,,.pJWT)
    
    If $$$ISERR(sc) {
        Write $SYSTEM.OBJ.DisplayError(sc)
    }
    
    Write pJWT
    Return sc
}
讨论 (0)1
登录或注册以继续
公告
· 一月 27

Concours InterSystems Full Stack 2026

Salut les développeurs !

Nous sommes ravis d'annoncer le premier concours de programmation en ligne InterSystems de l'année :

🏆 Concours InterSystems Full Stack 🏆

Durée : du 2 février au 1er mars 2026

Prix: 12 000 $


Sujet :

Développer une solution complète utilisant InterSystems IRIS, InterSystems IRIS for Health ou IRIS Cloud Service comme backend. Par solution complète, nous entendons une application web ou mobile frontend permettant d’insérer, de mettre à jour ou de supprimer des données dans InterSystems IRIS via une API REST, une API native, ODBC/JDBC ou Python embarqué.

Exigences générales :

  1. Une application ou une bibliothèque doit être entièrement fonctionnelle. Il ne doit pas s'agir d'un import ou d'une interface directe pour une bibliothèque déjà existante dans un autre langage (sauf pour le C++, là il faut vraiment faire beaucoup de travail pour créer une interface pour Iris). Il ne doit pas s'agir d'un copier-coller d'une application ou d'une bibliothèque existante.
  2. Applications acceptées : nouvelles applications sur Open Exchange ou existantes, mais avec une améliorations significatives. Notre équipe examinera toutes les candidatures avant de les approuver pour le concours.
  3. L'application doit fonctionner sur IRIS Community Edition, IRIS for Health Community Edition ou IRIS Cloud SQL. Les deux peuvent être téléchargés en tant que versions hôtes (Mac, Windows) à partir du site d'évaluation, ou peuvent être utilisés sous la forme de conteneurs extraits d'InterSystems Container Registry ou de Community Containers : intersystemsdc/iris-community:latest ou intersystemsdc/irishealth-community:latest .
  4. L'application doit être Open Source et publiée sur GitHub ou GitLab.
  5. Le fichier README de l'application doit être en anglais, contenir les étapes d'installation, et la vidéo de démonstration ou/et une description du fonctionnement de l'application.
  6. Pas plus de 3 soumissions d’un développeur sont autorisées.

N.B. Nos experts auront le dernier mot quant à l'approbation ou non de la candidature au concours en fonction des critères de complexité et d'utilité. Leur décision est définitive et sans appel.

Prix ​​du concours :

1. Nomination des experts – les gagnants seront sélectionnés par l'équipe d'experts d'InterSystems :

🥇 1ère place - $5,000
🥈 2e place - $2,500
🥉 3e place - $1,000
🏅 4e place - $500
🏅 5e place - $300
🌟 6-10e places - $100

2. Gagnants de la communauté – candidatures qui recevront le plus de votes au total :

🥇 1ère place - $1,000 
🥈 2e place - $600
🥉 3e place - $300
🏅 4e place - $200
🏅 5e place - $100

❗ Si plusieurs participants obtiennent le même nombre de votes, ils sont tous considérés comme gagnants et la récompense est partagée entre eux.
❗ Les récompenses sont attribuées uniquement aux personnes pouvant prouver leur identité. En cas de doute, les organisateurs contacteront le ou les participants pour leur demander des informations complémentaires

Qui peut participer ?

Tout membre de la communauté de développeurs, à l'exception des employés d'InterSystems (sous-traitants ISC autorisés). Créer un compte !

Les développeurs peuvent s'associer pour créer une application collaborative. Autorisé de 2 à 5 développeurs dans une équipe.

N'oubliez pas de mettre en évidence les membres de votre équipe dans le README de votre application – profils d'utilisateurs DC.

Délais importants :

🛠 Phase de développement et d'inscription de l'application :

  • 2 février 2026 (00h00 HNE) : Début du concours.
  • 22 février 2026 (23h59 HNE) : Date limite de dépôt des candidatures.

 Période de vote:

  • 23 février 2026 (00h00 HNE) : Début des votes.
  • 1er mars 2026 (23h59 HNE) : Clôture des votes.

Remarque : Les développeurs peuvent améliorer leurs applications tout au long de la période d'inscription et de vote.

    Ressources utiles :

    ✓ Exemples d'applications :

    ✓ Modèles à partir desquels nous vous suggérons de commencer :

    ✓ Pour les débutants avec IRIS :

    ✓ Pour les débutants avec ObjectScript Package Manager (IPM) :

    ✓ Comment soumettre votre application au concours :

    Besoin d'aide ?

    Rejoignez la chaîne du concours sur le serveur Discord d'InterSystems ou discutez avec nous dans les commentaires de ce post.

    Nous avons hâte de voir vos projets! Bonne chance 👍


    En participant à ce concours, vous acceptez les conditions du concours énoncées ici. Veuillez les lire attentivement avant de continuer.

    讨论 (0)1
    登录或注册以继续
    公告
    · 一月 27

    新的人工智能 CCR 助手

    CCR 现在包括一个人工智能驱动的 "CCR 助手",可供测试人员使用。CCR 助手可帮助您快速获得有关常见 CCR 工作流程、术语或最佳实践的答案。每个回复都包含相关 ICC 培训课程的参考资料,方便您深入了解任何主题。作为未来的改进,这些链接将直接指向用于生成回复的 ICC 培训 PDF 的特定页面。

    要访问该助手,请点击 CCR 应用程序右下方的蓝色 "打开 CCR 助手 "图标。对话会在浏览器会话中保存,但会在注销时清除。

    您可以通过点击 "竖起大拇指 "或 "摁下大拇指 "按钮并输入可选评论来提交对任何回复的反馈意见。我们非常感谢您的反馈,这将有助于我们继续提高回复质量!

    要试用 CCR 助手,请导航到侧边栏的用户菜单,选中您的个人资料下的测试版测试员复选框,然后单击保存。您可以随时取消选中该复选框。

    有关 CCR 助手的快速操作演示,请观看下面的视频。

    讨论 (0)1
    登录或注册以继续
    问题
    · 一月 27

    JDBC Connection Issue: Cache 2018.1 Access Denied

    Hello Community,

    I am facing a JDBC connection issue after migrating from Caché 2016 to Caché 2018.1. When I attempt to connect using the following connection settings:

    CACHE_DATASOURCE_URL=jdbc:Cache://localhost:1972/TEST

    CACHE_DB_USERNAME=test

    CACHE_DB_PASSWORD=test
     

    I consistently receive the following error:

    [Cache JDBC] Communication link failure: Access Denied
    

    This configuration worked perfectly with Caché 2016. I have verified the following:

    1. The namespace (TEST) exists and is correctly specified in the connection URL.
    2. The credentials (username: test, password: test) are correct.
    3. The Caché instance is running on the correct hostname and port (localhost:1972)

    Has anyone encountered a similar issue? Are there any known differences or required configurations for JDBC connections in Caché 2018 that weren’t present in Caché 2016?

    I appreciate any guidance or support.

    Thank you!

    7 条新评论
    讨论 (7)2
    登录或注册以继续
    讨论 (0)1
    登录或注册以继续