Alamofire: CredStore - performQuery - Error copying matching creds. Error=-25300 for every request

What did you do?

Make an HTTP request using SessionManager.request(_ url: URLConvertible, method: HTTPMethod = default, parameters: Parameters? = default, encoding: ParameterEncoding = default, headers: HTTPHeaders? = default) -> DataRequest

What did you expect to happen?

The request to work, and not spit up errors

What happened instead?

Every request I hit prints this out: 2018-03-13 11:17:00.732122-0600 MYAPP[1452:694869] CredStore - performQuery - Error copying matching creds. Error=-25300, query={ class = inet; “m_Limit” = “m_LimitAll”; “r_Attributes” = 1; sync = syna; }

According to this answer: https://stackoverflow.com/a/46806008/3877767 it seems to be related to Credential Storage, but I don’t use that for anything so it seems to be something Alamofire is doing

I found this bit of code in Request.swift that seems to be responsible for the error, but I’m not sure how to silence/handle this error

    if let credentialStorage = self.session.configuration.urlCredentialStorage {
        let protectionSpace = URLProtectionSpace(
            host: host,
            port: url.port ?? 0,
            protocol: url.scheme,
            realm: host,
            authenticationMethod: NSURLAuthenticationMethodHTTPBasic
        )

        if let credentials = credentialStorage.credentials(for: protectionSpace)?.values {
            for credential in credentials {
                guard let user = credential.user, let password = credential.password else { continue }
                components.append("-u \(user):\(password)")
            }
        } else {
            if let credential = delegate.credential, let user = credential.user, let password = credential.password {
                components.append("-u \(user):\(password)")
            }
        }

Alamofire Environment

Alamofire version: Alamofire 4.7.0 Xcode version: Version 9.2 (9C40b) Swift version: 4.0 Platform(s) running Alamofire: iOS 11.0+ macOS version running Xcode: 10.13.4 Beta (17E182a)

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Reactions: 25
  • Comments: 16 (2 by maintainers)

Most upvoted comments

In my research I’ve found many others seeing this same error (like CouchBase), and they all point to it being a spurious bit of debug info printed to the console when the credential store fails to find an item for a protection space. This is expected if you’re querying the store but nothing’s been stored in it yet, which is why even Apple’s framework code sees it. I’m guessing this is yet more debug output that’s now visible due to some Apple change. Nothing for us to do here.

In Alamofire Request.swift there a function, cURLRepresentation(). In the function it access URLCredentialStorage: if let credentials = credentialStorage.credentials(for: protectionSpace)?.values { for credential in credentials { guard let user = credential.user, let password = credential.password else { continue } components.append("-u \(user):\(password)") } }

and cURLRepresentation() is called when access debugDescription variable: open var debugDescription: String { return cURLRepresentation() }

So… in my case… debug code, print(), triggered the error log. Alamofire.upload( multipartFormData: { MultipartFormData in }, to: "https://xxx.yyy.com/aaa.php") { (result) in print("result: \(result)") }

Is it expected behavior to access URLCredentialStorage whenever printing debug description even though I don’t use URLCredentialStorage?

It made me confused and I had to find out what was wrong.