Chilkat Examples

ChilkatHOMEAndroid™Classic ASPCC++C#Mono C#.NET Core C#C# UWP/WinRTDataFlexDelphi ActiveXDelphi DLLVisual FoxProJavaLianjaMFCObjective-CPerlPHP ActiveXPHP ExtensionPowerBuilderPowerShellPureBasicCkPythonChilkat2-PythonRubySQL ServerSwift 2Swift 3/4TclUnicode CUnicode C++Visual Basic 6.0VB.NETVB.NET UWP/WinRTVBScriptXojo PluginNode.jsExcelGo

PowerShell Examples

ASN.1
Amazon S3
Amazon S3 (new)
Amazon SES
Amazon SNS
Amazon SQS
Async
Azure Cloud Storage
Azure Service Bus
Base64
Bounced Email
Box
CSR
CSV
Certificates
Compression
DKIM / DomainKey
DSA
Diffie-Hellman
Digital Signatures
Dropbox
Dynamics CRM
ECC
Email Object
Encryption
FTP
Facebook
FileAccess
Firebase
GMail REST API
GeoOp
Google APIs
Google Calendar
Google Cloud Storage
Google Drive
Google Sheets
Gzip
HTML-to-XML/Text
HTTP
HTTP Misc
IMAP
JSON
JSON Web Encryption (JWE)
JSON Web Signatures (JWS)
JSON Web Token (JWT)

Java KeyStore (JKS)
Jira
MHT / HTML Email
MIME
Microsoft Graph
NTLM
OAuth1
OAuth2
OneDrive
OpenSSL
Outlook
PEM
PFX/P12
POP3
PRNG
PayPal
Peoplevox
QuickBooks
REST
REST Misc
RSA Encryption
SCP
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
SharePoint
Shopify
Socket/SSL/TLS
Spider
Stream
Stripe
SugarCRM
Tar Archive
Twitter
Upload
VoiceBase
Walmart
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Xero
Zip
curl
eBay

 

 

 

(PowerShell) Export Private Keys from Java KeyStore to JWK Set

Demonstrates 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.

Chilkat .NET Downloads

Chilkat .NET Assemblies

Chilkat for Mono

Chilkat for Xamarin

[Reflection.Assembly]::LoadFile("C:\myAssemblies\ChilkatDotNet2.dll")

#  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.

$jks = New-Object Chilkat.JavaKeyStore

$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 -ne $true) {
    $($jks.LastErrorText)
    exit
}

#  Export to JWK Set format.
#  (Exports the compact 1-line JSON string to a StringBuilder..)
$sbJwkSet = New-Object Chilkat.StringBuilder
$success = $jks.ToJwkSet($jksPassword,$sbJwkSet)
if ($success -ne $true) {
    $($jks.LastErrorText)
    exit
}

#  To get in human-readable format, load into a JSON object and emit non-compact.
$json = New-Object Chilkat.JsonObject
$json.LoadSb($sbJwkSet)
$json.EmitCompact = $false
$($json.Emit())

#  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"
#      }
#    ]
#  }

 

© 2000-2016 Chilkat Software, Inc. All Rights Reserved.