I want to connect to Wi-Fi programmatically using swift in my iPad application and I want to create according to bellow flow.
- Enter the network name programmatically
- Set the programmatically "WAP2-Enterprise" for security.
- Set username/password.
- A certificate popup will appear, so tap "Trust".
- "Turn on the following information." otherwise off.
- Automatic connection
- Restrict IP address tracking
- Set the programmatically IPV4 address below.
- Configure ID: Manual
- IP address: 192.***.***.***
- For tablets, ○○: 1 to 20
- Subnet mask: 255.255.255.0
- Router: 192.***.***.***
- Configure DNS server(Set the programmatically)
- Manual
- Add server: 8.8.8.8
- HTTP proxy(Set the programmatically)
- Configure proxy: off
if anyone you can guide me to proper way much a appreciated!!!
You can’t pass certificate data directly to setTrustedServerCertificates(_:)
. It’s docs are pretty clear about this:
An array of SecCertificate objects …
Your app must store the certificates in keychain access group
$(TeamIdentifierPrefix)com.apple.networkextensionsharing
. The OS usesSecItemCopyMatching(_:_:)
to obtain a persistent reference to each certificate from the application’s keychain and uses it during EAP authentication.
Here’s a snippet of code that illustrates this process:
let eap: NEHotspotEAPSettings = …
let cert: SecCertificate = …
try secCall {
SecItemAdd([
kSecValueRef: cert,
kSecAttrAccessGroup: "TTTTTTTTTT.com.apple.networkextensionsharing",
] as NSDictionary, nil)
}
let success = eap.setTrustedServerCertificates([cert])
Some notes:
-
Replace
TTTTTTTTTT
with your Team ID. -
Make sure that your app is entitled to use the
TTTTTTTTTT.com.apple.networkextensionsharing
keychain access group. -
You can find the
secCall(…)
helpers here.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"