How to load a secured wms layer with client certificate?

403
0
02-23-2020 06:50 PM
PatrickLi
New Contributor

Hi, I'm new to ios app development and new to authentication stuff. Any help is very much appreciated.

SDK version: Arcgis sdk for IOS version 100.7

I need to load wms layer from a secured https server with client certifiate, p12 format. Below is my code to get AGDCredential object. I can get SecIdentityRef as below, but its value is changing each time i run the app, is it normal? 2nd, AGSCredential doesn't have initWithIdentityRef method which is presented in api reference. I try to use either AGSCredential(identityRef: secidref) or AGSCredential.init(identityRef: secidref) to get an AGSCredential, the result is always nil.

<SecIdentityRef: 0x600002cf5080>

let path: String = Bundle.main.path(forResource: "client_certificat_ename", ofType: "p12")!

        let PKCS12Data:NSData = NSData(contentsOfFile:path)!

        print(PKCS12Data)

        //var err:NSError? = nil

        let idRef = try! AGSCredential.importCertificateData(PKCS12Data as Data, password: "mypassword", overwrite: true)

        print(idRef)

        let secidref = idRef.takeRetainedValue()

        print("secidref:")

        print(secidref)

        let cred = AGSCredential(identityRef: secidref)

        print("cred:")

        print(cred)

        let host:NSString? = cred.authenticatingHost() as NSString?

        print(host)

0 Kudos
0 Replies