Resources.openrawresource unresolved reference

I’m new to Kotlin. I’m trying to permit an Https connection, using the Trust Manager. My domain is self-signed, so I saved the certificate into the project res/raw folder. Trying to build up certificate, I wanted to use the (***) instruction, which is not resolved. I refer to API 28, Android Studio 3.4.2, Kotlin plugin version 1.3.41. Would anybody help me please?

            // Load CAs from an InputStream
            val cf: CertificateFactory = CertificateFactory.getInstance("X.509")

*** val caInput : InputStream = Resources.openRawResource(R.raw.srvca3)
val ca: X509Certificate = caInput.use {
cf.generateCertificate(it) as X509Certificate

            val keyStoreType = KeyStore.getDefaultType()
            val keyStore = KeyStore.getInstance(keyStoreType).apply {
                load(null, null)
                setCertificateEntry("ca", ca)

            // Create a TrustManager that trusts the CAs inputStream our KeyStore
            val tmfAlgorithm: String = TrustManagerFactory.getDefaultAlgorithm()
            val tmf: TrustManagerFactory = TrustManagerFactory.getInstance(tmfAlgorithm).apply {

Is this Resources the android.content.res.Resources class? Then openRawResource(int) is instance method, not static method there. You need to have some instance (an object) of Resources type to call the method on it. Like:

fun yourFun(resources1: Resources) { // Pass it.
     var resources2: Resources = ... // Or create it.

How to correctly get it I don’t know, sorry.

Thank you a lot! And so, how can I initialize Resources instance, that is an object of class Resources?

var resources2: Resources = ??? // Or create it.

Shortly speaking, I don’t know. The way to work with Android resources should be more or less the same as with Java. Please refer to Android documentation.