To enable the commands on a Symfony application, you have to install and add the associated bundle into your kernel:
If you use Symfony Flex, you have nothing to do. Otherwise you have to enable to bundle.
Then execute your Symfony Console command to use the command provided by this component:
To install the application, you just have to download it and download the associated public key (the application is digitally signed):
If everything is fine, you should have two files:
jose.phar
jose.phar.pubkey
You can move these files wherever you want (e.g. /usr/local/bin
).
To use it, just execute the following line:
The application can be updated easily:
If a new version exists, it will be downloaded automatically. If there is something wrong with the new version, you can reinstall the previous revision:
The project comes with console commands. They are available:
In the following example, we will call commands using ./jose.phar
. If you need more information about a command, call the command with the option --help
.
This command will convert a private key into a public key. It has no effect on shared keys (e.g. oct
keys).
The following command will analyze the key passed as argument and find issues.
This command will convert a RSA or EC key into PKCS#1 key.
The key generator commands will generate a private or shared key. The following options are available:
-o
or --out
: save the output into a file: --out private.key
.
-u
or --use
: indicates the usage of the key (sig
or enc
): --use enc
. This option is highly recommended.
-a
or --alg
: indicates the algorithm to be used with the key: --alg RSA-OAEP-256
. This option is highly recommended.
Elliptic Curve Key
This command will generate an Elliptic Curve key (EC). The supported curves are P-256
, P-384
and P-521
.
RSA Key
This command will generate a RSA key. The key size must be at least 384 bits. Recommended size is 2048 bits or more.
Octet Key
This command will generate a octet key (oct). Recommended size is 128 bits or more.
Octet Key Pair Key
This command will generate a octet key pair key (OKP). Supported curves are X25519
(for encryption only) and Ed25519
(signature only).
None Key
This command will generate a none key. This key type is only used by the none
algorithm. Key parameters alg
and use
are automatically set.
From An Existing Secret
This feature was introduced in version 1.1.
If you already have a secret, you can use it to create an octet key (oct
).
In case your secret is binary string, you will have to encode it first (Base64) and indicate it is encoded.
The key loader commands will loader keys from various sources. The following options are available:
-o
or --out
: save the output into a file: --out private.key
.
-u
or --use
: indicates the usage of the key (sig
or enc
): --use enc
. This option is highly recommended.
-a
or --alg
: indicates the algorithm to be used with the key: --alg RSA-OAEP-256
. This option is highly recommended.
Convert From PEM/DER Keys
This command can load and convert a DER/PEM key file into a JWK. It supports encrypted keys as well as PKCS#1 and PKCS#8 encodings or public/private keys.
Convert From PKCS#12 Keys
This command can load and convert a PKCS#12 key file into a JWK. It supports encrypted keys.
Convert From A X.509 Certificate
This command can load and convert a X.509 key file into a JWK.
This command optimizes a RSA key by calculating additional primes (CRT). The following option is available:
-o
or --out
: save the output into a file: --out private.key
.
RSA keys generated by this framework are already optimized. This command may be needed when you import RSA keys from external sources. The optimization is not mandatory but highly recommended. cryptographic operations are up to 10 times faster.
This command will calculate the key thumbprint as per the RFC7638. The following options are available:
-o
or --out
: save the output into a file: --out private.key
.
--hash
: the hashing method. Default is sha256
. Supported methods are the one listed by hash_algos
.
This command has the same affect as key:convert:public
except that it will convert all keys in the keyset. It has no effect on shared keys (e.g. oct
keys).
This command has the same behaviour as key:analyze
except that it will analize all keys in the keyset.
The key set generator commands will generate key sets with random keys of the same type.
These commands have the same options as the key generator commands. The only difference is that you have to indicate the number of keys you want in the key set.
Examples:
The result of these commands is a JWKSet object.
keyset:add:key
: Add a key into a key set.
keyset:merge
: Merge several key sets into one.
keyset:rotate
: Rotate a key set.
keyset:load:jku
: Loads a key set from an url.
keyset:load:x5u
: Loads a key set from an url.