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
(Objective-C) 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.
#import <CkoJavaKeyStore.h> #import <NSString.h> #import <CkoStringBuilder.h> #import <CkoJsonObject.h> // 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. CkoJavaKeyStore *jks = [[CkoJavaKeyStore alloc] init]; NSString *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. BOOL success = [jks LoadFile: jksPassword path: @"qa_data/jks/test_secret.jks"]; if (success != YES) { NSLog(@"%@",jks.LastErrorText); return; } // Export to JWK Set format. // (Exports the compact 1-line JSON string to a StringBuilder..) CkoStringBuilder *sbJwkSet = [[CkoStringBuilder alloc] init]; success = [jks ToJwkSet: jksPassword sbJwkSet: sbJwkSet]; if (success != YES) { NSLog(@"%@",jks.LastErrorText); return; } // To get in human-readable format, load into a JSON object and emit non-compact. CkoJsonObject *json = [[CkoJsonObject alloc] init]; [json LoadSb: sbJwkSet]; json.EmitCompact = NO; NSLog(@"%@",[json Emit]); // Sample output: // { // "keys": [ // { // "kty": "RSA", // "n": "yADdNtY3GcgAfwUhvf-ETRbcLFUaecY7lR9UWvBPW6zbzgvUwJRIcxadWFmtFXGZKxLXjKUmNjH8bm9d-cv2l1am1_s-FJN05qxGGNYvQ8EE6BFIkbgREMtpJ9F_BRjuurcIiilYGZ7FxMZDWb5Y5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d0", // "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" // } // ] // } |
© 2000-2024 Chilkat Software, Inc. All Rights Reserved.