Certificate Schema Violation

Hi. I was trying to add a certificate to kong. I’ve used this command to first generate the pem files

openssl req -newkey rsa:2048 -nodes -keyout key.pem -x509 -days 365 -out certificate.pem

then i used the contents of key.pem and certificate.pem to add the certificate via kong admin

{
 "cert": "-----BEGIN CERTIFICATE-----...-----END CERTIFICATE-----",
"key": "-----BEGIN PRIVATE KEY-----...-----END PRIVATE KEY-----",
 "snis":"abcd"
}

as mentioned here: Admin API - v1.1.x | Kong Docs (konghq.com)

but it shows me schema violation error:

{
    "name": "schema violation",
    "fields": {
        "key": "invalid key: pkey.new:load_key: pem/pem_lib.c:745:error:0909006C:PEM routines:get_name:no start line",
        "cert": "invalid certificate: x509.new: asn1/tasn_dec.c:309:error:0D07803A:asn1 encoding routines:asn1_item_embed_d2i:nested asn1 error"
    },
    "message": "2 schema violations (cert: invalid certificate: x509.new: asn1/tasn_dec.c:309:error:0D07803A:asn1 encoding routines:asn1_item_embed_d2i:nested asn1 error; key: invalid key: pkey.new:load_key: pem/pem_lib.c:745:error:0909006C:PEM routines:get_name:no start line)",
    "code": 2
}

how can this be resolved?

Any help on this woud be appreciated!