joaovictortinoco
joaovictortinoco

Reputation: 45

Swift Invalid passphrase when connecting to SSID

I'm trying to connect programmatically using NEHotspotConfiguration (see code below). However, when i try to connect, the error says : "invalid WPA/WPA2 passphrase length", but i'm connecting an open network with no password required.

I've seen some solutions but there are a lot of workarounds that i cannot use because of quality purposes.

let wifiConfig = NEHotspotConfiguration(ssid: SSID, passphrase: "", isWEP: false)

    wifiConfig.joinOnce = false

    NEHotspotConfigurationManager.shared.apply(wifiConfig) { error in

        if let error = error{
            print("Error: " + (error.localizedDescription))
        }else {
            print("Connected.")
        }
    }

What could i do to fix it?

Upvotes: 1

Views: 1246

Answers (1)

user1531971
user1531971

Reputation:

There is a specific API for open networks. Looking at the API docs for NEHotspotConfiguration it looks like you should be using init(ssid: String) instead of init(ssid: String, passphrase: String, isWEP: Bool)

Upvotes: 2

Related Questions