# Connecting Moodle to LTI

**URL:** https://meta.discourse.org/t/connecting-moodle-to-lti/230500
**Category:** Support
**Tags:** lti
**Created:** [October 6, 2021, 12:12am UTC](https://meta.discourse.org/t/connecting-moodle-to-lti/230500 "2021-10-06T00:12:42Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![fishfree](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fishfree/32/235911_2.png) [@fishfree](https://meta.discourse.org/u/fishfree)
#### Post date: [October 6, 2021, 12:12am UTC](https://meta.discourse.org/t/connecting-moodle-to-lti/230500/1 "2021-10-06T00:12:42Z")

</div>

@david David, would you please share a configuration instance with me? I tried many times for integrating Discourse with Moodle 3.10, but still no luck. Always said:

```plaintext
OpenSSL::PKey::RSAError (Neither PUB key nor PRIV key: nested asn1 error)
lib/middleware/omniauth_bypass_middleware.rb:50:in `call'
lib/content_security_policy/middleware.rb:12:in `call'
lib/middleware/anonymous_cache.rb:355:in `call'
config/initializers/100-quiet_logger.rb:23:in `call'
config/initializers/100-silence_logger.rb:31:in `call'
lib/middleware/enforce_hostname.rb:23:in `call'
lib/middleware/request_tracker.rb:187:in `call'

```

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [October 6, 2021, 9:34am UTC](https://meta.discourse.org/t/connecting-moodle-to-lti/230500/2 "2021-10-06T09:34:09Z")

</div>

What have you entered in the “platform public key” setting? If I remember correctly, Moodle provides a JWKS url by default, which this plugin doesn’t support.

It should be possible to find the raw certificate somewhere, which you can copy/paste into Discourse,

---

<div class="post-metadata">

### Author: ![fishfree](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fishfree/32/235911_2.png) [@fishfree](https://meta.discourse.org/u/fishfree)
#### Post date: [October 7, 2021, 11:58am UTC](https://meta.discourse.org/t/connecting-moodle-to-lti/230500/3 "2021-10-07T11:58:22Z")

</div>

@david Thank you for replying me. Yes. In Moodle. it showed `Public keyset URL: https://mysiet.com/mod/lti/certs.php`.  
I opened this URL in browser, it showed as below:

```plaintext
{
    "keys": [
        {
            "kty": "RSA",
            "alg": "RS256",
            "kid": "1371e22ce81f1dbb936a",
            "e": "AQAB",
            "n": "xXOfRS1UronVdVUEal0jyIhyNkAcbCRb6K2uzLsoQgRAaqA2ixbshCTWW_Yj-ZoJgg7UoruO65TB5EIldMyPJbYjYoMF0rB5a-wcvEhtWxfLs8FsDNLM9czjYXZUXBJ6sxIGNp-9Wp4c6PaecvXDfc4bJoHU8Ee5WzUk2XuX8dXX4jx8ipwzRa8qaQT-0cIPnZw4LmkPiTgn-gA-LuqjG2w9awwjnWTuZbTNPTphgPO9FD4lD_dAY3biURU_lEyJXflqFYwbrpja-b8y23qixwiHEYsM3_2F5D-DrI3Nsty219-ALDmJ0wY1hnr4p2NfwYZr_d2YjpIiJW_8iW3SRQ",
            "use": "sig"
        }
    ]
}

```

I copied the value of “n” in the json (the longest one) into Discourse. But still the same error.

---

<div class="post-metadata">

### Author: ![david](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/david/32/157490_2.png) [@david](https://meta.discourse.org/u/david)
#### Post date: [October 7, 2021, 12:42pm UTC](https://meta.discourse.org/t/connecting-moodle-to-lti/230500/4 "2021-10-07T12:42:23Z")

</div>

I don’t think copying the `n` value will be enough - discourse needs the key in the PEM format. Long-term we might be able to add support for JWKs, but in the short term you should be able to get it working by converting the key.

There are some online tools which can convert from JWKs format into PEM. [Here’s one](https://8gwifi.org/jwkconvertfunctions.jsp). (Obviously I can’t guarantee the safety of these online tools, so make sure you only paste public information into them)

Once you have the PEM (starting with `-----BEGIN PUBLIC KEY-----`, then Discourse should accept it.
