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

Classic ASP Examples

Web API Categories

ASN.1
Amazon Glacier
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
FileAccess
Firebase
GMail REST API
Google APIs
Google Calendar
Google Cloud Storage
Google Drive
Google Photos
Google Sheets
Google Tasks
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)
MHT / HTML Email
MIME
Microsoft Graph
NTLM
OAuth1
OAuth2
OneDrive
OpenSSL
Outlook
PEM
PFX/P12
POP3
PRNG
REST
REST Misc
RSA Encryption
SCP
SFTP
SMTP
SSH
SSH Key
SSH Tunnel
SharePoint
Socket/SSL/TLS
Spider
Stream
Tar Archive
Upload
WebSocket
XAdES
XML
XML Digital Signatures
XMP
Zip
curl

 

 

 

(Classic ASP) Load a JWK Set into a JCEKS (Convert JWK Set to JCEKS)

Demonstrates how to convert JSON Web Key Sets to JCEKS format.

This example uses the JWK sample files that you may download from Sample JWK Sets

This example requires Chilkat v9.5.0.66 or greater.

Chilkat ActiveX Downloads

ActiveX for 32-bit and 64-bit Windows

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
'  IMPORTANT: This example requires Chilkat v9.5.0.66 or greater.

'  This example requires the Chilkat API to have been previously unlocked.
'  See Global Unlock Sample for sample code.

set jceks = Server.CreateObject("Chilkat_9_5_0.JavaKeyStore")

'  First load the following JWK Set (found in secretKeys.json)

'  {
'    "keys": [
'      {
'        "kty": "oct",
'        "alg": "AES",
'        "k": "vHekQQB0Gc1NvppapUTW2g",
'        "kid": "my aes key"
'      },
'      {
'        "kty": "oct",
'        "alg": "BLOWFISH",
'        "k": "qHsdXaJsXicVCZbK8l8hJQpYOa0GkiO9gsRK9WLtht8",
'        "kid": "my blowfish key"
'      },
'      {
'        "kty": "oct",
'        "alg": "HMAC_SHA256",
'        "k": "VGhpcyBpcyBteSBITUFDIGtleQ",
'        "kid": "my hmac key"
'      },
'      {
'        "kty": "oct",
'        "alg": "CHACHA",
'        "k": "yNv832U43C9BcWvaQAH2_rG-GwfmpgT5JBRllWGQY1o",
'        "kid": "my chacha20 key"
'      }
'    ]
'  }

set jwkSet = Server.CreateObject("Chilkat_9_5_0.JsonObject")
success = jwkSet.LoadFile("qa_data/jwk/secretKeys.json")
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( jwkSet.LastErrorText) & "</pre>"
    Response.End
End If

'  The password is applied to each of the keys in the set.
'  (It is the password that will be required to access the item after the JCEKS is opened.)
password = "secret"
success = jceks.LoadJwkSet(password,jwkSet)
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( jceks.LastErrorText) & "</pre>"
    Response.End
End If

'  Write the JCEKS to a file, then examine with a tool such as the KeyStore Explorer
'  to verify that all is OK.  (The "kid" becomes the alias of each key.)
filePassword = "secret2"
success = jceks.ToFile(filePassword,"qa_output/secretKeys.jceks")
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( jceks.LastErrorText) & "</pre>"
    Response.End
End If

'  -------------------------------------------------------------------------
'  Now load a JWK Set that contains one ECC private key (and certs)
'  This is the JSON that is loaded from ecc_jwkset.json:

'  {
'    "keys": [
'      {
'        "kty": "EC",
'        "crv": "P-384",
'        "x": "uB62JGMJKXnp1PNsOOIYKGhrzfLev3O-UuthL6UzEqNNDTd8dEYMUQP_DTS3qk98",
'        "y": "gyQEFxdmZUsPF0fFokkZZ1cV6z7QD3MsPvSjrBzB0GUB3r8CLnDK_F4pF2Q995hr",
'        "d": "ugTy2ZpuQqv1uQyLSgz1SPRvngzrd5vLyzU2ICaJd25zZRIxxlNR-uFo9UWC6llt",
'        "kid": "my_ecc_key",
'        "x5c": [
'          "MIICzjCCAlOgAwIBAgIETULS8zAKBggqhkjOPQQDAzBtMQswCQYDVQQGEwJVUzEWMBQGA1UEChMNRW50cnVzdCwgSW5jLjEfMB0GA1UECxMWRm9yIFRlc3QgUHVycG9zZXMgT25seTElMCMGA1UEAxMcRW50cnVzdCBFQ0MgRGVtb25zdHJhdGlvbiBDQTAeFw0xNjAzMTgxMjM5MzFaFw0xNjA1MTcxMzA5MzFaMFgxHzAdBgNVBAsTFkZvciBUZXN0IFB1cnBvc2VzIE9ubHkxHTAbBgNVBAsTFFBlcnNvbmEgTm90IFZlcmlmaWVkMRYwFAYDVQQDEw1DaGlsa2F0IEFkbWluMHYwEAYHKoZIzj0CAQYFK4EEACIDYgAEuB62JGMJKXnp1PNsOOIYKGhrzfLev3O+UuthL6UzEqNNDTd8dEYMUQP/DTS3qk98gyQEFxdmZUsPF0fFokkZZ1cV6z7QD3MsPvSjrBzB0GUB3r8CLnDK/F4pF2Q995hro4HYMIHVMA4GA1UdDwEB/wQEAwIDiDAdBgNVHSUEFjAUBggrBgEFBQcDAgYIKwYBBQUHAwQwNwYDVR0fBDAwLjAsoCqgKIYmaHR0cDovL2NybC5lbnRydXN0LmNvbS9DUkwvZWNjZGVtby5jcmwwIAYDVR0RBBkwF4EVYWRtaW5AY2hpbGthdHNvZnQuY29tMB8GA1UdIwQYMBaAFCQFS+Fkghr4Ccz7eHkh+nDmkzLqMB0GA1UdDgQWBBTB82fmvrdG2iX5uS/agVW3L4DisjAJBgNVHRMEAjAAMAoGCCqGSM49BA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adFile("qa_data/jwk/ecc_jwkset.json")
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( jwkSet.LastErrorText) & "</pre>"
    Response.End
End If

password = "secret"
success = jceks.LoadJwkSet(password,jwkSet)
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( jceks.LastErrorText) & "</pre>"
    Response.End
End If

filePassword = "secret2"
success = jceks.ToFile(filePassword,"qa_output/ecc.jceks")
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode( jceks.LastErrorText) & "</pre>"
    Response.End
End If

Response.Write "<pre>" & Server.HTMLEncode( "Success.") & "</pre>"

%>
</body>
</html>

 

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