Chilkat HOME .NET Core C# Android™ AutoIt C C# C++ Chilkat2-Python CkPython Classic ASP DataFlex Delphi ActiveX Delphi DLL Go Java Lianja Mono C# Node.js Objective-C PHP ActiveX PHP Extension Perl PowerBuilder PowerShell PureBasic Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ VB.NET VBScript Visual Basic 6.0 Visual FoxPro Xojo Plugin
(DataFlex) Export Private Keys from Java KeyStore to JWK SetDemonstrates how to export the private keys from a Java KeyStore to a JWK Set. Each private key alias is exported to the "kid" parameter. Note: This example requires Chilkat v9.5.0.66 or greater.
Use ChilkatAx-win32.pkg Procedure Test Handle hoJks String sJksPassword Boolean iSuccess Variant vSbJwkSet Handle hoSbJwkSet Handle hoJson String sTemp1 // This requires the Chilkat API to have been previously unlocked. // See Global Unlock Sample for sample code. // Note: This example requires Chilkat v9.5.0.66 or greater. Get Create (RefClass(cComChilkatJavaKeyStore)) To hoJks If (Not(IsComObjectCreated(hoJks))) Begin Send CreateComObject of hoJks End Move "secret" To sJksPassword // Load the Java keystore from a file. The JKS file password is used // to verify the keyed digest that is found at the very end of the keystore. // It verifies that the keystore has not been modified. Get ComLoadFile Of hoJks sJksPassword "qa_data/jks/test_secret.jks" To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoJks To sTemp1 Showln sTemp1 Procedure_Return End // Export to JWK Set format. // (Exports the compact 1-line JSON string to a StringBuilder..) Get Create (RefClass(cComChilkatStringBuilder)) To hoSbJwkSet If (Not(IsComObjectCreated(hoSbJwkSet))) Begin Send CreateComObject of hoSbJwkSet End Get pvComObject of hoSbJwkSet to vSbJwkSet Get ComToJwkSet Of hoJks sJksPassword vSbJwkSet To iSuccess If (iSuccess <> True) Begin Get ComLastErrorText Of hoJks To sTemp1 Showln sTemp1 Procedure_Return End // To get in human-readable format, load into a JSON object and emit non-compact. Get Create (RefClass(cComChilkatJsonObject)) To hoJson If (Not(IsComObjectCreated(hoJson))) Begin Send CreateComObject of hoJson End Get pvComObject of hoSbJwkSet to vSbJwkSet Get ComLoadSb Of hoJson vSbJwkSet To iSuccess Set ComEmitCompact Of hoJson To False Get ComEmit Of hoJson To sTemp1 Showln sTemp1 // Sample output: // { // "keys": [ // { // "kty": "RSA", // "n": "yADdNtY3GcgAfwUhvf-ETRbcLFUaecY7lR9UWvBPW6zbzgvUwJRIcxadWFmtFXGZKxLXjKUmNjH8bm9d-cv2l1am1_s-FJN05qxGGNYvQ8EE6BFIkbgREMtpJ9F_BRjuurcIiilYGZ7FxMZDWb5Y5PLmW3JWJzUcCBgchMThzn68m0YpJjxqiVO1LLA-zULccjYyYXpSo0VWNxxaedm7DkJujADJ0-fKtX82vtGKnj8-zvF72CZf_DMhIirIK4Ryzz23-LbNY0b0BS_IQxybZxWpiI8hptciUIaIBIszii-0q3VH5pw0qL8Ec4BiA9pDzThgad3LBdySA-RcPxym6Q", // "e": "AQAB", // "d": "U63o4DSoQSUo7_wZrgDmPcq-u92vghuqei3tgU7iJR0hqgfRL_Hajix8EKcUf9BToW30uWevoSUw1JPL4eOwfIlIrTz1MG6xjoGtol6az-JGR0JT9oPov_obOQmx91QDLiO-cu_xaGbBoB7Dtxyo3MG0F7ayzRyvacOMyxAE2fv24ypb2cYiVNKrsYIGm1QvXvsbkBHW9cCxTSRR3J-jKeYt6X2Lge08z6XpuT7i-a1F_fPKRPWzMwgW1AunHa5GZBAuFZt3_Nv5Gg1RcIOZbax4Xm_7plSFXs76byDFrDQbx9KthTLdGRblRlXMaWmtGBHAmPqcAP45zRCLEO53cQ", // "p": "8uWk3bslzAYbtpxbQumWqIIeMurtH5CEOQv1NzGYLb8q4JRp9mysG1gsJk9_D5-JyqYZd4jkCj9pHgrY5q4J9LmVtJMUsl7m7qp7zqgWK2Q1pOTFH7bwa7omGUqqmSYJdA6rWqq3hiOPOtu5uQgZA0zZCX6o8Y19E55jdI1qM2M", // "q": "0sreI4hZKsC3crSA026bfAWBsqbwBgBr06gOiWl6p4xTRV8dVUtKyMA51_CRSu06oQ4zP6TRGnbPq9CHJIMRN15hX7J5iLJA-ApjgFRItPAvUeEkxha9CfwtCMEqw0Zea1-FH-mLQZ9nJeXyoHnjBpmz_pKE-5HlbJbtKsCCPEM", // "dp": "I2UPZzg0Q8zIEQ4rxk5fo-KCIA1XzHe0rNNvQkG52UC4MM2vuzcOxVVN6a8_5rjqzVry7xZFlLC00qnl_Ydy7_RzOkMMiwmFQVYagHzB7kTGBGdJyltQIYKYtqrIvVRroDvbAHVMFQHthzgpkir56h8yqU2JtNlXVpqIB53r0d0", // "dq": "zGHXMSyrCEEDnjxWDKtaJs5QCyDB6Y_O_NIeBi43tuzgcIrgrirqv-tiKnYe6j9KcY6LMlJkTPyWL0lpP4W107G3SEqMfHYZeGbaQzt1o7qepw1d0pOJh3zzTWG-TMiWFBXxxhdz5pTgNmbW8bI85dFyLIt0VVgI01kjbChsHnE", // "qi": "52wp71nLXtQwu7bH-yYp8No4ru3Vbr6BjzzN7kXTwxLmalzQFRkDUcKzYuOpwgJwCj0REsAnIGXKT4p6PXouzxGFad7dFEINrt3ezXUkN0HVobu0GoOTjlQqJHrkDJM111UVrAgQlr7BVIsx_FbE9hbpGlkeTmim_FCBa12CJhY", // "kid": "test" // }, // { // "kty": "EC", // "crv": "P-256", // "x": "MKBCTNIcKUSDii11ySs3526iDZ8AiTo7Tu6KPAqv7D4", // "y": "4Etl6SRW2YiLUrN5vfvVHuhp7x8PxltmWWlbbM4IFyM", // "d": "870MB6gfuTJ4HtUnUvYMyJpr5eUZNP4Bk43bVdj3eAE", // "kid": "1" // } // ] // } End_Procedure |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.