Core WLAN

RSS for tag

Provide APIs for querying AirPort interfaces and choosing networks using Core WLAN.

Core WLAN Documentation

Pinned Posts

Posts under Core WLAN tag

21 Posts
Sort by:
Post not yet marked as solved
3 Replies
109 Views
With the deprecation of the airport binary in macOS 14.4 I am re-writing my own network tool to directly use CoreWLAN. In doing this and testing and comparing to previous results from the Apple airport binary under various versions of macOS I believe CoreWLAN has a 'bug' which as a result was exhibited in the Apple airport binary and equally my own code. As detailed below. This applies to the release version of macOS 14.4 (23E214) macOS Sonoma 14.3.1 and previous versions of macOS going back many, many years have included an official Apple binary at the following location. /System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport Whilst this is now officially deprecated in macOS 14.4 it is obvious that this tool will have itself been utilising the official Apple framework CoreWLAN. As part of the process of re-writing my own tool which formerly used the above Apple binary, I have re-written my tool to directly utilise CoreWLAN myself via the Objc interface. In doing this I have been able to in my own tool reproduce an incorrect behaviour formerly exhibited by the airport binary and still exhibited with my own tool directly utilising CoreWLAN. It therefore appears the issue is in CoreWLAN and not the now deprecated airport binary. Using the airport binary in macOS 14.3.1 (the last working version) I get a result like the following. SSID BSSID RSSI CHANNEL HT CC SECURITY (auth/unicast/group) vodafone20645C -89 6 Y -- RSN(PSK/AES/AES) vodafone20645C -89 60 Y -- RSN(PSK/AES/AES) You can see the column for CC which stands for country code is empty and hence shows ‘--‘. This field should indicate the country the WiFi access point is configured to support. (This affects the available choices of WiFi channels, transmitter strength and other aspects in order to render the access point LEGAL to use in various countries.) Using my own code under the same version of macOS written to directly call CoreWLAN and obtain the same information I get the same results i.e. CoreWLAN does not return any country code information. My code under both macOS 14.3.1 and 14.4 returns the same results i.e. no country code. As a comparison here is the output from the airport binary included in macOS 12.7.4 (21H1123) SSID BSSID RSSI CHANNEL HT CC SECURITY (auth/unicast/group) vodafone20645C -89 6 Y -- RSN(PSK/AES/AES) vodafone20645C -89 60 Y -- RSN(PSK/AES/AES) As you can see it is identical confirming this bug has existed for a long time. To show this however DID NOT USE TO EXIST here is the result from a much older macOS X Yosemite 10.10.5 (14F2511) SSID BSSID RSSI CHANNEL HT CC SECURITY (auth/unicast/group) VM2833142 cc:58:30:07:32:48 -88 108 Y NL WPA2(PSK/AES/AES) EE WiFi 62:e5:32:e3:ab:35 -61 11 Y GB NONE EV home 78:85:f4:42:02:58 -57 11 Y CN WPA2(PSK/AES/AES) SKYGW3RD 3c:45:7a:fe:6b:0a -63 11 Y -- WPA2(PSK/AES/AES) BT-6FCW7K c4:e5:32:e3:ab:34 -61 11 Y GB WPA2(PSK/AES/AES) As you can see in this case it is listing access points that are set to respectively, Netherlands, Great Britain, China, ‘Unknown’, and Great Britain. (As an aside and not part of this bug I am reporting, CoreWLAN has not reported the BSSID aka MAC address for some time either.) Note: The countryCode field is still defined in CoreWLAN as retrieving it does not generate an error unlike picking a non-existent field name. See also - https://developer.apple.com/documentation/corewlan/cwinterface/countrycode()
Posted Last updated
.
Post not yet marked as solved
3 Replies
145 Views
I have a Python script that returns a scan result with scanForNetworksWithName using CoreWLAN with PyObjC. It provides info on ssid and such like the airport command. When upgrading to MacOS 14.4 however SSID is now Null. I read this was due to changes in permissions and location services needed to be enabled. I have enabled access to location services and I am able to use CoreLocation to get a location however I still do now see the SSID. Here is my script, that does both location and scan: import CoreWLAN import CoreLocation from time import sleep import re wifi_interface = CoreWLAN.CWInterface.interface() networks, error = wifi_interface.scanForNetworksWithName_error_(None, None) location_manager = CoreLocation.CLLocationManager.alloc().init() location_manager.startUpdatingLocation() max_wait = 60 # Get the current authorization status for Python for i in range(1, max_wait): authorization_status = location_manager.authorizationStatus() if authorization_status == 3 or authorization_status == 4: print("Python has been authorized for location services") break if i == max_wait-1: exit("Unable to obtain authorization, exiting") sleep(1) coord = location_manager.location().coordinate() lat, lon = coord.latitude, coord.longitude print("Your location is %f, %f" % (lat, lon)) print(f"{'SSID' : >32} {'BSSID' : <17} RSSI CHANNEL HT CC SECURITY") for i in networks: print(f"{'SSID' : >32} {'BSSID' : <17} RSSI CHANNEL HT CC SECURITY") for i in networks: print(f"{i.ssid() or '' : >32} {i.bssid() or '' : <17} {i.rssiValue() : <4} {i.channel() : <6}") It worked fine in MacOS 13.6 but with MacOS 14.4 I have the null SSID issue. We went through something similar with MacOS 10.15 where BSSID became Null. At the time I couldn't find a workaround, but sometime around MacOS 13.x I was able to generate the request for location services. After granting the request I was able to see BSSID again. It seems like we have a similar bug to this again. Thread about the BSSID issue: https://github.com/ronaldoussoren/pyobjc/issues/484
Posted
by thewade.
Last updated
.
Post not yet marked as solved
2 Replies
542 Views
In the context of a system utility that reports OS stats periodically, the security type for a connected WiFi network could be obtained with Core WLAN via CWInterface.security. This used to work up to Ventur; howver, after upgrading to Sonoma, cwInterface.security now returns kCWSecurityUnknown. In other posts, I have read about changes in how Core WLAN works which are related to Sonoma. How can I determine the security type for a connected WiFi network on Sonoma? It would be preferable if the suggested approach would also work on previous macOS versions as well. Many thanks in advance! :-)
Posted
by fsauter.
Last updated
.
Post marked as Apple Recommended
3.5k Views
I've had a little personal utility running for several versions of macOS that uses let client = CWWiFiClient.shared() if let ssid_name = client.interface()?.ssid() to get the current SSID name and prints it (along with a bunch of other active network details. With the most recent Sonoma Beta 2 and Xcode beta 2, this always returns nil. Doing the same thing in a playground works as expected. Is this a purposeful change or a bug I should file?
Posted
by ehemmete.
Last updated
.
Post not yet marked as solved
1 Replies
186 Views
TL;DR What's the replacement via CLI, programmatically, &| reliable AppleScript-fu. Scenario Auto-switching between Ethernet adapters (i.e., built-in MAC official/unofficial Ethernet adapters, third-party 10 GbE USB-C), and Wi-Fi. Problem Standard operation in post-Network Location macOS leads to assigning multiple IP addresses, causing havoc with applications and network services. Disabling Wi-Fi manually is non-starter. Goal Disassociate from Wi-Fi programmatically or from the CLI without powering off Wi-Fi to retain Wi-Fi PAN services such as AirDrop and AirPlay. (Previous) Solution Calls airport -z when needed to disassociate. Re-associate with other magic tools when Ethernet becomes unreachable. It worked reliably for over a year. Invocation sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/Current/Resources/airport -z Expected (previous) behavior Wi-Fi disassociates but remains powered on Actual behavior Output WARNING: The airport command line tool is deprecated and will be removed in a future release. For diagnosing Wi-Fi related issues, use the Wireless Diagnostics app or wdutil command line tool. (nothing happens) Platform 14.4 (23E214) m1/arm64
Posted
by pdp-12.
Last updated
.
Post not yet marked as solved
1 Replies
84 Views
Our company's application is aimed at lot applications. When configuring device networking, we want users to select a certain WiFi information in the WiFi list. When we apply for a WiFi list, Apple asks us what protocol to choose and how to choose it? Our application's communication is done through HTTPS.
Posted
by yecao007.
Last updated
.
Post not yet marked as solved
3 Replies
609 Views
It was possible to excute: sudo /System/Library/PrivateFrameworks/Apple80211.framework/Versions/A/Resources/airport -s on previous mac os version to get all SSID list. But now on mac os 14.4 it returns like: WARNING: The airport command line tool is deprecated and will be removed in a future release. For diagnosing Wi-Fi related issues, use the Wireless Diagnostics app or wdutil command line tool. Is there any other way to list all SSIDs? It's important to me since my code depends on this feature. P.S. Seems other airport command like "airport -I" didn't work too. Is there any other tool could replace airport?
Posted Last updated
.
Post marked as solved
2 Replies
162 Views
Hi, I am trying to get a list of available WiFi networks for a sandboxed macOS app: CWInterface *wifi = [[CWWiFiClient sharedWiFiClient] interface]; NSError *err; NSSet *scanset = [wifi scanForNetworksWithSSID:nil error:&err]; // scanset is always empty (but not nil), no error is writting to "err" With macOS Sonoma the code always returns an empty list (with older macOS version it works fine). I already added Location permission (as described here: https://developer.apple.com/forums/thread/732431). Getting the currently connected WiFi SSID (using [CWInterface interface].ssid), as well as connecting to a WiFi network works. How can I get a list of available WiFi SSIDs in macOS Sonoma? Regards,
Posted
by HMoc.
Last updated
.
Post not yet marked as solved
8 Replies
461 Views
Hello Experts, After updating to Mac OS sonoma, I am not able to get SSID info and going through already issue, I can see that on update location access is mandatory to get SSID info from API - scanForNetworksWithName:includeHidden:error: Now my application is already able to get latitude and longitude info, but when I call API mentioned above, it gives nil in ssid name field. Questions - Is there any known issue? Is there any other better way to get CWNetwork object so that I can use it directly instead of scanning and then connecting? Note - I have created app package, but application has no GUI. Application is also combination of Golang and Objective-C
Posted
by tejask.
Last updated
.
Post not yet marked as solved
4 Replies
866 Views
FB12755685 Sent a feedback through feedback assistant and wanted to elaborate more over here. Our application configures and connects to wireless networks using CoreWLAN. We started seeing crashes while connecting with the latest Beta versions of Sonoma. The crashes showed EXC_BAD_INSTRUCTION (code=EXC_I386_INVOP, subcode=0x0) which led me to believe it might be a CPU architecture issue due to the mention of i386 but that was completely wrong. Turns out the error is due to: *** CFRetain() called with NULL *** CFRetain.cold.1 [CWInterface associateToEnterpriseNetwork:identity:username:password:error:] + 127 Sample code to consistently reproduce the crash on Sonoma CWInterface* interface = [CWInterface interfaceWithName:@“en0”]; NSError *scanError = nil; NSSet* testNetworks = [interface scanForNetworksWithName:@“SSIDName” error:&amp;testScanError]; CWNetwork* network = [testNetworks anyObject]; NSError* connectionError = nil; BOOL connected = [interface associateToEnterpriseNetwork:network identity:identityRef username:nil password:nil error:&amp;connectionError]; //&lt;--crash here The associateToEnterpriseNetwork function expects a CWNetwork object. In the Beta versions of macOS Sonoma, the CWNetwork object has (null) values in the ssid field. This causes a cold CFRetain runtime error when trying to associate to the network. If we can detect a broadcasting "SSIDName" SSID and try to associate to it, we will always crash on the last line. The reason for the crash seems to be due to a difference in how the CWNetwork objects are handled in Sonoma. Sonoma: &lt;CWNetwork: 0x6000036cb590&gt; [ssid=(null), bssid=(null), security=WPA2 Enterprise, rssi=-53, channel=&lt;CWChannel: 0x6000036fce90&gt; [channelNumber=1(2GHz), channelWidth={20MHz}], ibss=0] Ventura: &lt;CWNetwork: 0x6000010ffa60&gt; [ssid=Chris640, bssid=(null), security=WPA2 Enterprise, rssi=-45, channel=&lt;CWChannel: 0x6000010ffca0&gt; [channelNumber=1(2GHz), channelWidth={20MHz}], ibss=0] Is my assumption that the crash is due to the (null) in the SSID field correct?
Posted
by pyro_90.
Last updated
.
Post not yet marked as solved
3 Replies
548 Views
Hi Quinn, I have a macOS App (SwiftUI) which scans for available WifiNetworks using CWWiFiClient.shared().interface().scanForNetworks(withSSID: nil) The app is sandboxed and has "Outgoing Connections" (Client) checked. The app is Launched via a "LaunchAgents". During app init() I kickoff the scanForNetworks in a background thread. I do receive WifiNetworks but when I look at the SSID quite often all of the SSIDs are nil. If I loop the scanForNetworks() a few times with a delay of 1 second after a few tries the SSIDs will no longer be nil. Any idea why this happens? Should I file a bug report or is that expected behavior Thanks very much, Martin (your old friend from Germany)
Posted
by Besti.
Last updated
.
Post not yet marked as solved
1 Replies
680 Views
Hi, Question: Is there a way to detect Captive network and show the UI to authenticate to it from within a third party app/plugin on macOS? I tried using URLSession to detect the presence of captive portal by loading the detection URL http://captive.apple.com/hotspot-detect.html but the task fails with no internet connection error without the delegate getting any calls about redirect or auth challenge. Same behavior with WKWebView when I try to load the detection URL, the provisional navigation simply fails with no internet connection error. Context: I'm building an Auth plugin to do something before users log in to their mac and it requires internet connectivity. I wanted to let the users connect to a wifi network if they aren't already connected. I got connecting to regular networks working but not the captive networks.
Posted
by santhoshr.
Last updated
.
Post marked as solved
3 Replies
631 Views
Hello! Is it possible to add location permissions to a macOS system extension? We have a network firewall system extension that also considers WIFI connections in its rules. With the release of Sonoma, interface information is only accessible while having location permissions, which we are having trouble asking for. We have the entitlements, the usage description, but the authorizationStatus of CLLocationManager stays at .notDetermined and no window for location permission pops up after calling requestAlwaysAuthorization(). What we need is to get the SSID of the network that the interface is connected, its security and encryption type. If the permission is not possible, is there a workaround? Cheers
Posted Last updated
.
Post not yet marked as solved
8 Replies
924 Views
Hi Team, I have been recently working on MacOS native application which interactes with Native API's to fetch SSID but recently this below mentioned API is returning nil as response on Sonoma OS Version. Below is the Objective - C for code reference CWWiFiClient *client = [CWWiFiClient sharedWiFiClient]; CWInterface *interface = [client interface]; NSString *ssid = [interface ssid]; I'm referring to following API - https://developer.apple.com/documentation/corewlan/cwwificlient?language=objc And trying to retrieve ssid https://developer.apple.com/documentation/corewlan/cwinterface?language=objc Note : The API is working on MacOS 13.0+ version and this seems to have broken in 14.0+ version Could you please provide us more details on the API issue, or any alternatives that can be followed, because from the documentation the above code seems to be a valid operation and nothing that is deprecated or restricted.
Posted Last updated
.
Post not yet marked as solved
2 Replies
533 Views
After the upgrade of Sonoma 14.0 (23A344), after the 802.1x connection is successful, the system will send logoff and then fail. It is normal before the upgrade, but after the upgrade of the system. How can I view more detailed information? I'm sure it's an update to Sonoma 14.0 (23A344), which has been tested on multiple machines. Please help me!
Posted
by ChianTec.
Last updated
.
Post not yet marked as solved
3 Replies
625 Views
Hi Experts, I am working on a application where I am calling Objective-C Core WLAN API from golang with below code, darwin_lib.m void ConnectWiFi(char * cInterfacename, char * cSSID, char * cSecurity, char *cSubsecurity, char * cPassphrase, char * cOnexuser, char * cOnexpass) { @autoreleasepool { NSString * interfacename = [[NSString alloc] initWithUTF8String:cInterfacename]; NSString * ssid = [[NSString alloc] initWithUTF8String:cSSID]; NSString * security = [[NSString alloc] initWithUTF8String:cSecurity]; NSString * subsecurity = [[NSString alloc] initWithUTF8String:cSubsecurity]; NSString * passphrase = [[NSString alloc] initWithUTF8String:cPassphrase]; NSString * onexuser = [[NSString alloc] initWithUTF8String:cOnexuser]; NSString * onexpass = [[NSString alloc] initWithUTF8String:cOnexpass]; NSError * connecterr = nil; CWWiFiClient * cwwificlient = [CWWiFiClient sharedWiFiClient]; CWInterface *a = [cwwificlient interfaceWithName:interfacename]; NSSet<CWNetwork *> * network = [a scanForNetworksWithName:ssid error:&connecterr]; **** some more code ***** BOOL result = [a associateToEnterpriseNetwork:network.anyObject identity:nil username:onexuser password:onexpass error:&connecterr]; main.go package main // #cgo CFLAGS: -x objective-c // #cgo LDFLAGS: -framework CoreWLAN // #cgo LDFLAGS: -framework Foundation // #include "clib.h" import "C" import "fmt" func main() { var status C.int = C.ConnectWiFi() time.Sleep(20) *** some more code and long running process *** } Now what I am trying to understand here from memory release point of view is, Is object created in C code will be freed once I reach time.Sleep(20) e.g cwwificlient a spcifically to Core WLAN side or do I have to call release specifically on object? I tried calling release on cwwificlient and program is crashing on second execution, not sure why it would crash on only second execution, why not first time itself? I tried calling release on a and program is not crashing. Do I have to free all the Core WLAN related object myself or autoreleasepool will take care of it? As whole code is inside autoreleasepool, will all the objects be released on it's own even though function is being called from go code? As go's garbage collector has no idea how many objects C code created so go's garbage collector won't be of any help here Is autoreleasepool, can also take care of releasing any alloc object e.g ssid created inside C code ?
Posted
by tejask.
Last updated
.
Post not yet marked as solved
4 Replies
736 Views
Hello Experts, I am trying to connect Mac Pro through command line utility using Mac OS API. I am successfully able to connect client though when network goes down and comes up again, on GUI dialog is again asking for username and password even though it was connected earlier. So I tried to use helper method CWKeychainSetWiFiEAPUsernameAndPassword but unfortunately it is giving error code -108 Error: 0xFFFFFF94 -108 Failed to allocate memory. My little code snippet looks as below, BOOL result = [a associateToEnterpriseNetwork:network.anyObject identity:nil username:onexuser password:onexpass error:&amp;connecterr]; NSLog(@"Association Result: %d", result); NSLog(@"Error: %@", connecterr); NSData *nssid = [network.anyObject ssidData]; CWKeychainDomain d = kCWKeychainDomainUser; OSStatus er = CWKeychainSetWiFiEAPUsernameAndPassword(kCWKeychainDomainUser, nssid, onexuser, onexpass); NSLog(@"Status: %d", er); Now I am not sure what could be the cause of error? Any pointers would be appreciated.
Posted
by tejask.
Last updated
.
Post not yet marked as solved
2 Replies
920 Views
I have a macOS background app which runs with a launchd daemon plist. The app has core location permissions. I was able to get BSSID until macOS Monterey. But with upgrade to ventura, I see that when I run the app with xcode or terminal, I see the BSSID. But when I try to run the app with a launchd daemon plist, the BSSID is empty/nil. Any help?
Posted Last updated
.
Post not yet marked as solved
5 Replies
1.4k Views
I use CoreWLAN for Wi-Fi connection, since macOS 12.5, Wi-Fi can't connect automatically after restarting the computer. rememberJoinedNetworks is set to true. Same problem with EAP-PEAP, EAP-TLS. Can't find "com.apple.network.eap.user.item.wlan.ssid" item in keychain.  Here is my code: BOOL success = [interface associateToEnterpriseNetwork:selectedNetwork                            identity:nil                            username:username                            password:password                             error:&err];
Posted
by mashroom.
Last updated
.
Post not yet marked as solved
2 Replies
787 Views
Hi Experts, I am connecting to SSID with API associateToEnterpriseNetwork:identity:username:password:error: I am successfully able to connect Problem is when I turn off/on my wifi, it can not connect to SSID back again without asking username and password Wondering if there is any way to store this permanently into key store so user do not have to enter it again? Any hint here would be helpful.
Posted
by tejask.
Last updated
.