# Add own RSA key to realm via API

**URL:** <https://forum.keycloak.org/t/add-own-rsa-key-to-realm-via-api/15358>\
**Category:** Getting advice\
**Tags:** admin-console\
**Created:** [May 4, 2022, 11:25am UTC](https://forum.keycloak.org/t/add-own-rsa-key-to-realm-via-api/15358 "2022-05-04T11:25:13Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![tobiashrs](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/tobiashrs/32/5742_2.png) [@tobiashrs](https://forum.keycloak.org/u/tobiashrs)\
**Post date:** [May 4, 2022, 11:25am UTC](https://forum.keycloak.org/t/add-own-rsa-key-to-realm-via-api/15358/1 "2022-05-04T11:25:13Z")

</div>

Hello folks,

I want to provide my own RSA key to a realm via API to sign tokens. I already searched for similar topics but didnt succeed with the proposed answers.

Playing with the admin cli brought me to ‘kcadm.sh create components -r testrealm -s name=rsa -s providerId=rsa -s providerType=org.keycloak.keys.KeyProvider’ so far but asks for the key.  
Where can I look up the arguments for a valid key request and is the command directly translatable to json?

---

<div class="post-metadata">

**Author:** ![tobiashrs](https://yyz2.discourse-cdn.com/free1/user_avatar/forum.keycloak.org/tobiashrs/32/5742_2.png) [@tobiashrs](https://forum.keycloak.org/u/tobiashrs)\
**Post date:** [May 5, 2022, 7:58am UTC](https://forum.keycloak.org/t/add-own-rsa-key-to-realm-via-api/15358/2 "2022-05-05T07:58:12Z")

</div>

Alright, I found it out myself. All attributes regarding key import can be found here: [keycloak/Attributes.java at 10c3e149d36d0be1e421ff149359c854cc0ed8f0 · keycloak/keycloak · GitHub](https://github.com/keycloak/keycloak/blob/10c3e149d36d0be1e421ff149359c854cc0ed8f0/services/src/main/java/org/keycloak/keys/Attributes.java)

To make it work remove PEM header and footer from both key and certificate.

The cli command then looks like: kcadm.sh create components -r testrealm -s name=rsa -s providerId=rsa -s providerType=org.keycloak.keys.KeyProvider -s ‘config.privateKey=["$key"]’ -s ‘config.certificate=["$certificate"]’
