CredStore Perform Query error

前端 未结 12 1514
北荒
北荒 2020-11-27 12:16

I am running into an issue while doing API calls to my apps backend, every connection now prompts with

CredStore - performQuery - Error copying matching cred         


        
相关标签:
12条回答
  • 2020-11-27 12:36

    I got this issue when I tried to open a http-page inside a web-view. But this page contained an popup which was opened first.

    When backend team removed this popup everything became OK.

    0 讨论(0)
  • 2020-11-27 12:39

    This error occurs when trying to retrieve an URLCredential from URLCredentialStorage for an unknown URLProtectionSpace. e.g.

    let protectionSpace = URLProtectionSpace.init(host: host, 
                                                  port: port, 
                                                  protocol: "http", 
                                                  realm: nil, 
                                                  authenticationMethod: nil)
    
    var credential: URLCredential? = URLCredentialStorage.shared.defaultCredential(for: protectionSpace)
    

    produces

    CredStore - performQuery - Error copying matching creds.  Error=-25300, query={
        class = inet;
        "m_Limit" = "m_LimitAll";
        ptcl = http;
        "r_Attributes" = 1;
        srvr = host;
        sync = syna;
    }
    

    Give it a credential for the protection space:

    let userCredential = URLCredential(user: user, 
                                       password: password, 
                                       persistence: .permanent)
    
    URLCredentialStorage.shared.setDefaultCredential(userCredential, for: protectionSpace)
    

    and the error goes away next time you try to retrieve the credential.

    I am a little lost as I am not sure what is causing this, or what CredStore even does. What purpose does CredStore serve in iOS?

    Credential storage on iOS allows users to securely store certificate-based or password-based credentials on the device either temporarily or permanently to the keychain.

    I suspect that you have some sort of authentication on your backend server and that server is requesting an authentication challenge to your app (for which no credential exists).

    It can probably be safely ignored as returning nil from the URLCredentialStorage is a valid response

    0 讨论(0)
  • 2020-11-27 12:42

    The error may also be caused by a Content Security Policy (CSP) that may be too restrictive. In our case, we needed a CSP that is more or less completely open and allows everything. Keep in mind that opening the CSP can be a great security issue (depending on what exactly you're doing in the app).

    0 讨论(0)
  • 2020-11-27 12:47
        let credentialData = "\(user):\(password)".data(using: String.Encoding.utf8)!
        let base64Credentials = credentialData.base64EncodedString(options: [])
        let headers = ["Authorization": "Basic \(base64Credentials)"]
        Alamofire.request(url, method: .get, parameters: params,encoding: URLEncoding.default,headers: headers)
                    .responseJSON{
                response in
                guard let value =  response.result.value else {return}
                        print(value)
         }
    
    0 讨论(0)
  • 2020-11-27 12:49

    In my case, I was not initialising Stripe SDK with API key.

            STPPaymentConfiguration.shared().publishableKey = publishableKey
    

    In case of any Stripe operation, we can print the error log, its easy to understand.

            print(error.debugDescription)
    
    0 讨论(0)
  • 2020-11-27 12:50

    If you get this error, when using AVPlayer, just call .play() on main thread

    0 讨论(0)
提交回复
热议问题