Chilkat HOME Android™ Classic ASP C C++ C# Mono C# .NET Core C# C# UWP/WinRT DataFlex Delphi ActiveX Delphi DLL Visual FoxPro Java Lianja MFC Objective-C Perl PHP ActiveX PHP Extension PowerBuilder PowerShell PureBasic CkPython Chilkat2-Python Ruby SQL Server Swift 2 Swift 3,4,5... Tcl Unicode C Unicode C++ Visual Basic 6.0 VB.NET VB.NET UWP/WinRT VBScript Xojo Plugin Node.js Excel Go
(Excel) 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.
' 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. Dim jks As Chilkat.JavaKeyStore Set jks = Chilkat.NewJavaKeyStore jksPassword = "secret" ' 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. success = jks.LoadFile(jksPassword,"qa_data/jks/test_secret.jks") If (success <> True) Then Debug.Print jks.LastErrorText Exit Sub End If ' Export to JWK Set format. ' (Exports the compact 1-line JSON string to a StringBuilder..) Dim sbJwkSet As Chilkat.StringBuilder Set sbJwkSet = Chilkat.NewStringBuilder success = jks.ToJwkSet(jksPassword,sbJwkSet) If (success <> True) Then Debug.Print jks.LastErrorText Exit Sub End If ' To get in human-readable format, load into a JSON object and emit non-compact. Dim json As Chilkat.JsonObject Set json = Chilkat.NewJsonObject Dim success As Boolean success = json.LoadSb(sbJwkSet) json.EmitCompact = False Debug.Print json.Emit() ' Sample output: ' { ' "keys": [ ' { ' "kty": "RSA", ' "n": "yADdNtY3GcgAfwUhvf-ETRbcLFUaecY7lR9UWvBPW6zbzgvUwJRIcxadWFmtFXGZKxLXjKUmNjH8bm9d-cv2l1am1_s-FJN05qxGGNYvQ8EE6BFIkbgREMtpJ9F_BRjuurcIiilYGZ7FxMZDWb5Y5PLmW3JWJzUcCBg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"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" ' } ' ] ' } |
© 2000-2022 Chilkat Software, Inc. All Rights Reserved.