I've implemented a custom VPN app for macOS (using Packet Tunnel Provider). I set includeAllNetworks at the protocolConfiguration. When this field is set, I can't connect and I can't send traffic even at the extension. Even simple calls at the extension, like getaddrinfo or curl fails.
If I'm unsetting this variable (includeAllNetworks = false) then I can connect without a problem.
In addition I can see those lines at the Xcode Console:
Connection 2: encountered error(1:53)
Connection 3: encountered error(1:53)
Connection 1: encountered error(1:53)
And those lines at the Console:
No mDNS_Keepalive for interface en8/IOSkywalkLegacyEthernetInterface kr 0xE00002C0
NetWakeInterface: en8 <private> no WOMP
uDNS_CheckCurrentQuestion: host unreachable error for DNS server <private> for question
failed to send packet on InterfaceID 0x5 en8/4 to <private>:53 skt 74 error -1 errno 65 (No route to host)
Selecting any option will automatically load the page
Post
Replies
Boosts
Views
Activity
I've implemented a custom system-extension VPN (Packet Tunnel Provider) for macOS.
At the extension, I need to use a 3rd party dynamic lib.
The steps I did:
Build phases:
Copy files, with Frameworks destination
Link Binary With Libraries
Build Settings:
I set 'Dynamic Library Install Name', 'Dynamic Library Install Name Base', and 'Library Search Path' to the lib folder
I set 'Header Search Path' to the headers folder
But when running the extension, it's crashing with the error
Termination Reason: Namespace DYLD, Code 1 Library missing
Library not loaded: @loader_path/somelib.dylib
And
Reason: tried: '/Library/SystemExtensions/A1111-someID-11111/com.myapp.myappSysExtension.systemextension/Contents/MacOS/libwavmodapi.dylib' (no such file), '/usr/local/lib/libwavmodapi.dylib' (no such file), '/usr/lib/libwavmodapi.dylib' (no such file)
(terminated at launch; ignore backtrace)
Any idea what I'm doing wrong here?
Also, is it even possible to use dynamic libs from a sys-ext?
At my app I have a SecKey which I want to sign some Data with it, and at my sever I need to do the verification process, but this time with openSSL.
I didn't find any common key or any steps to achieve this between Apple Security framework and OpenSSL.
For example, I've tried the following:
Signing (Apple Security):
let signedStrCFData = SecKeyCreateSignature(key, .rsaSignatureRaw, plaintextData, &error)
Verifying (OpenSSL):
ret = RSAverify(NIDrsaSignature, (const unsigned char *)challenge, (unsigned int)strlen(challenge), challengeenc,
challengeenc_size, rsa); Which key to choose is not really important to me (as long as it's a reasonable signing key), so I tried multiple types of keys, but I wasn't able to do it.
Any idea what I'm missing here?
Sry for the duplicate -
I added a comment on an old post, but it's tagged only with 'System Extension' and without 'Network Extension', so I'm posting it here as well:
Original post:
https://developer.apple.com/forums/thread/133933?login=true&page=1#694688022
My question:
Bumping this old thread - I have the same scenario, I created a VPN + Certificate payload, installed it, and now I have a VPN conf which I can access to only from the containing app, but I need to access it from the system-extension. As I read above it's not possible, I send messages between the extension and the app, and it worked fine for the SecCertificate, which I sent as a Data to the extension (using SecCertificateCopyData() and sendProviderMessage functions).
The problem is that at the extension I need also the SecKey, and I couldn't find any way to pass it from the containing app to the extension. I even tried to pass it via IPC, but it crashed ( "This coder only encodes objects that adopt NSSecureCoding").
Is there any way to pass SecKey to the Extension, or to access it directly from there?
I've implemented a VPN app (with Packet tunnel Provider) for MacOS.Each user has a password, which I'm saving at the keychain with a persistentReference.For some users (not many), the app fails to save the password and I got error -25308 which is User interaction is not allowed.Why does it happening and how can I solve it?
As I mentioned in this thread
https://developer.apple.com/forums/thread/695207
I want my containing app to be active after Mac restarts.
I thought about something that could work - I wrote a "helper" embedded app which will be added to the login items, and after a restart this "helper" app will open the containing app.
However, after archiving the project (with developer ID, it will be distributed outside the App Store), I see the following error at the Console:
Non-fatal error enumerating at , continuing: Error Domain=NSCocoaErrorDomain Code=260 "The file “PlugIns” couldn’t be opened because there is no such file." UserInfo={NSURL=PlugIns/ -- file:///Applications/MyMainApp.app/Contents/Library/LoginItems/LauncherApplication.app/Contents/, NSFilePath=/Applications/MyMainApp.app/Contents/Library/LoginItems/LauncherApplication.app/Contents/PlugIns, NSUnderlyingError=0x7fc5cb02c6f0 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}}
I see that there's really no plugin folder, but why?
Is it a certificate/signing issue?
Topic:
App & System Services
SubTopic:
Drivers
Tags:
System Extensions
Developer ID
Network Extension
Hi
I've developed a custom VPN app for macOS (system-extension, Packet Tunnel Provider), and I have the following problem:
I'm connected vie Ethernet only (not Wi-Fi). I configured on the Ethernet interface HTTP and HTTPS proxies.
I'm connecting to my VPN:
If I'm using a 'full tunnel' - the traffic won't pass to the Ethernet proxies, this is expected
If I'm using a split tunnel - even the routes included on the tunnel will reach the Ethernet proxies, this is not expected.
Am I right that this behavior is not expected? How can I fix this issue?
I have an iOS app and a MacOS app in which I want to display to the user it's device's local IP.If there is more than one IP, I would dispaly one of them, not matter which one.This is the code I'm using:func getIFAddresses() -> String {
//var addresses = [String]()
var address = "N/A"
deviceLocalIp = "N/A"
// Get list of all interfaces on the local machine:
var ifaddr : UnsafeMutablePointer?
guard getifaddrs(&ifaddr) == 0 else { return address }
guard let firstAddr = ifaddr else { return address }
// For each interface ...
for ptr in sequence(first: firstAddr, next: { $0.pointee.ifa_next }) {
let flags = Int32(ptr.pointee.ifa_flags)
var addr = ptr.pointee.ifa_addr.pointee
// Check for running IPv4, IPv6 interfaces. Skip the loopback interface.
if (flags & (IFF_UP|IFF_RUNNING|IFF_LOOPBACK)) == (IFF_UP|IFF_RUNNING) {
if addr.sa_family == UInt8(AF_INET) || addr.sa_family == UInt8(AF_INET6) {
let interfaceName = String.init(cString: &ptr.pointee.ifa_name.pointee)
//DDLogInfo("interfaceName:\(interfaceName)")
// Convert interface address to a human readable string:
var hostname = [CChar](repeating: 0, count: Int(NI_MAXHOST))
if (getnameinfo(&addr, socklen_t(addr.sa_len), &hostname, socklen_t(hostname.count),
nil, socklen_t(0), NI_NUMERICHOST) == 0) {
if interfaceName == "en0" {
deviceLocalIp = String(cString: hostname)
address = deviceLocalIp
break
}
//if we don't have address from en0 - try get it from another interface
//(but prefer from en0)
if address == "N/A" && (interfaceName == "en0" || interfaceName == "en1" || interfaceName == "en2" || interfaceName == "pdp_ip" || interfaceName == "ap1") {
deviceLocalIp = String(cString: hostname)
address = deviceLocalIp
}
}
}
}
}
freeifaddrs(ifaddr)
return address
}
}For IPv4 it seems to work well.For IPv6 (via Mac's Internet Sharing), I'm getting an IPv6 address, but it's not the address I'm expecting to connect -at the Network I see that my device is connected and has the IP address X and the result I'm getting with this code is address Y.P.S -For debugging, I printed all the IPs, not just the first, and still didn't get the correct one..
I've implemented a custom system extension VPN for macOS using Packet Tunnel Provider.
The VPN is configured with on-demand, and a rule to always connect whenever there's traffic:
onDemandRules = [NEOnDemandRuleConnect()]
As for the tunnel's settings (at the Packet Tunnel Provider), I've configured a split tunnel, so some routes are excluded from the tunnel.
Now I have the following scenario:
The VPN is connected
The Mac enters sleep
The sleep() function is called (at my Packet Tunnel Provider)
The Mac briefly awakes to check emails/push notifications/etc. This traffic is excluded from the tunnel.
What is the expected behavior here? Should the wake function be called because of the on-demand rule? Or should the VPN remain asleep because this traffic is excluded from the tunnel?
I have a scenario where the user needs to login using SSO, and then the server will use a url-scheme to communicate with my app.
If I'm opening an external browser - everything works great.
But I tried to use an embedded browser instead (WebView), and for some reason I'm getting this unclear error:
[ProcessSwapping] 0x11fd863f0 - ProvisionalPageProxy::didFailProvisionalLoadForFrame: pageProxyID=23 webPageID=34, frameID=3, navigationID=4
At the Console I saw more similar issues, like:
0x11fd863f0 - ProvisionalPageProxy::didFailProvisionalLoadForFrame: pageProxyID=23 webPageID=34, frameID=3, navigationID=4
<nw_activity 16:1 [E08406EE-456B-4302-913A-6C46229FDFC7] (reporting strategy default) complete (reason cancelled)> complete with reason 4 (cancelled), duration 599ms
How can I tell what's the problem and how to fix it?
P.S
In order to debug/fix it, I tried to implement the WKNavigationDelegate protocol, so I could see
that I'm getting this error as well:
error:Error Domain= Code=0 "Redirection to URL with a scheme that is not HTTP(S)" UserInfo={_WKRecoveryAttempterErrorKey=<WKReloadFrameErrorRecoveryAttempter: 0x600002b1c200>, NSErrorFailingURLStringKey=mycustomurlscheme://someresponse
I'm not sure why the url scheme must be http(s) in this case.
I downloaded the ES sys-ext sample project. I built the 'NOTIFY' extension, and I was able to install it. However, it doesn't seem to work (or - it doesn't report anything).
This is what I did:
I download the project
I renamed the bundle IDs
I disabled SIP
I tried both signing options - let 'Xcode automatically manage signing', and I also tried to use my 'Developer ID'
I moved the app to the Applications folder
I grant the 'Full Disk Access' permission to the extension
I verified that the extension is running
I did not get the needed entitlement yet, but since SIP is disabled, I don't think it's a problem
I did get the message 'Successfully installed the extension ✅'
At the terminal, I tried to capture relevant logs:
log stream --style compact --predicate 'sender == "myBundleId"'
(I tried it with the app bundleID, and with the extension's bundleId)
And yet, 'ps' triggers no logs.
*At the Console, I get those messages:
"Unsatisfied entitlements: com.apple.developer.endpoint-security.client"
Disallowing: myBundleId
amfid: Restricted entitlements not validated, bailing out. Error: Error Domain=AppleMobileFileIntegrityError Code=-413 "No matching profile found" UserInfo={NSURL=, unsatisfiedEntitlements=, NSLocalizedDescription=No matching profile found}
Any idea where's the problem at?
I've implemented a custom VPN for macOS (system extension, Packet Tunnel Provider, Developer ID). My tunneling logic uses BSD sockets.
My VPN is configured with on-demand and should always connect when there's traffic:
targetManager?.isOnDemandEnabled = true
targetManager?.onDemandRules = [NEOnDemandRuleConnect()]
I have encountered some issues when the device enters sleep (or waking up from sleep). I've tried two scenarios.
Scenario 1:
protocolConfiguration?.disconnectOnSleep = true
With this flag set, the OS will disconnect the VPN just before entering to sleep. However, there were cases when the OS disconnected the VPN but immediately restarted it - probably because of how I defined the on-demand rules. This resulted in the VPN disconnection, then trying to reconnect, and then the Mac entered sleep.
When the Mac woke up, the VPN didn't work well.
Is there a way to avoid waking up, just before the Mac enters sleep?
Scenario 2:
protocolConfiguration?.disconnectOnSleep = false
Disconnect on sleep is unset, and I've implemented the sleep/wake functions at the provider.
With this configuration, the OS won't disconnect the VPN, so even in sleep, the extension should stay 'alive,' so it won't have the problem from (1).
But in this case, I had other problems:
On sleep, I'm disconnecting the tunnel. But sometimes, on wake(), all my network calls fail. Are the interfaces still down? How can I detect this case from the system extension?
Is it possible that the OS would call sleep and then quickly call wake?
Is it possible that after sleep, the OS would call the startTunnelWithOptions() function?
Is it possible to restart the extension from a clean state right from the wake() function?
I've implemented a custom VPN system extension for macOS, utilizing Packet Tunnel Provider.
One of the users reported a problem: he was connected to the VPN, and then his Mac entered sleep mode. Upon waking, the VPN is supposed to connect automatically (because of the on-demand rules).
The VPN's status changed to 'connecting', but it remained stuck in this status.
From my extension logs, I can see that the 'startTunnelWithOption()' function was called 2 minutes after the user clicked the 'connect' button.
From the system logs, I noticed some 'suspicious' logs, but I can't be sure if they are related to the problem. Some of them are:
kernel: (Sandbox) Sandbox: nesessionmanager(562) deny(1) system-fsctl (_IO "h" 47)
entitlement com.apple.developer.endpoint-security.client not present or not true (I don't need this entitlement at the extension)
nesessionmanager: [com.apple.networkextension:] NESMVPNSession[Primary Tunnel:XXXXXX(null)]: Skip a start command from YYYYY:session in state connecting
NetworkExtension.com.***: RunningBoard doesn't recognize submitted process - treating as a anonymous process
sysextd: activateDecision found existing entry of same version: state activated_enabled, ID FAE...
Are any of the logs related to the above problem? How can I debug such issues? What info should I get from the user?
I'm planning to covert my Network Extension to a System Extension (custom VPN, Packet Tunnel Provider, macOS).
I have some questions regarding this process: I'm using keychain groups, so I would be able to get the user's password from the keychain both from app and from the Extension, is it possible to do also with a system extension?
A similar question, but this time for a certificate - I have the entitlement for managed.vpn.shared - is it possible to use also from the system extension, and get the certificate for the VPN?
I'm passing data between the containing app and the extension via 'App Groups' ("shared" user defaults). Can I do the same for the system extension?
While working on a dev version of my custom macOS VPN (Network Extension, Packet Tunnel Provider), I had cases where the VPN was suppose to start, but it didn't.
It's configured with an on-demand rule to always connect, and also to be on the safe side, I called connection.startVPNTunnel()
From the Console logs I see the following:
myClientClient Saving configuration myClient example - myname_mfa.mynameaccount with existing signature {length = 20, bytes = 0x3be5a6633b963d04c5e0a226cccff4c83a799e14}
default 12:33:36.686853+0200 secd myClientClient[8416]/1#11 LF=0 copy_matching Error Domain=NSOSStatusErrorDomain Code=-50 "query missing class name" (paramErr: error in user parameter list) UserInfo={numberOfErrorsDeep=0, NSDescription=query missing class name}
default 12:33:36.687705+0200 myClientClient MacOS error: -25304
default 12:33:36.690077+0200 myClientClient MacOS error: -25304
NESMVPNSession[Primary Tunnel:myClient example - myname_mfa.mynameaccount:2A6C1B7D-19E8-4EF7-8872-C1D0F8899A17:(null)]: Received a start command from myClientClient[8416]
default 12:33:36.763724+0200 nesessionmanager Registering session NESMVPNSession[Primary Tunnel:myClient example - myname_mfa.mynameaccount:2A6C1B7D-19E8-4EF7-8872-C1D0F8899A17:(null)]
default 12:33:36.764739+0200 nesessionmanager Received a com.apple.neconfigurationchanged notification with token 23
default 12:33:36.765486+0200 nesessionmanager Clearing E853F1E7-23BD-4F01-915B-65DCBB9D9AB8 from the loaded configurations
default 12:33:36.765604+0200 nesessionmanager Clearing 8A4A1803-C370-42A1-8758-35E3D4337959 from the loaded configurations
default 12:33:36.765717+0200 nesessionmanager Clearing 2A6C1B7D-19E8-4EF7-8872-C1D0F8899A17 from the loaded configurations
nesessionmanager nw_network_agent_open_control_socket Successfully connected netagent socket 8
default 12:33:36.760869+0200 SystemUIServer Received a com.apple.neconfigurationchanged notification with token 48
default 12:33:36.790775+0200 neagent Looking for an extension with identifier com.myClientexample.mac.myClientClient.myClientClientExtension and extension point com.apple.networkextension.packet-tunnel
default 12:33:36.791728+0200 neagent [d private] PKHost:0x7f9bc9c29fb0 Beginning discovery for flags: 0, point: com.apple.networkextension.packet-tunnel
default 12:33:36.794692+0200 pkd Waiting on thread private until Launch Services database seeding is complete.
default 12:33:36.783780+0200 nesessionmanager NESMVPNSession[Primary Tunnel:myClient example - myname_mfa.mynameaccount:2A6C1B7D-19E8-4EF7-8872-C1D0F8899A17:(null)]: status changed to connecting
default 12:33:36.811018+0200 neagent [d private] PKHost:0x7f9bc9c29fb0 Completed discovery. Final of matches: 1
default 12:33:36.762607+0200 myClientClient startToggled
default 12:33:36.811362+0200 nesessionmanager com.myClientexample.mac.myClientClient[743]: disposing
default 12:33:36.811575+0200 nesessionmanager com.myClientexample.mac.myClientClient[743]: Tearing down agent connection
default 12:33:36.811641+0200 nesessionmanager NESMVPNSession[Primary Tunnel:myClient example - myname_mfa.mynameaccount:2A6C1B7D-19E8-4EF7-8872-C1D0F8899A17:(null)]: Plugin is installed
default 12:33:36.763228+0200 myClientClient starting vpn tunnel
default 12:33:36.811729+0200 nesessionmanager NESMVPNSession[Primary Tunnel:myClient example - myname_mfa.mynameaccount:2A6C1B7D-19E8-4EF7-8872-C1D0F8899A17:(null)]: Enabling VPN On Demand
default 12:33:36.811145+0200 neagent Found 1 extension(s) with identifier com.myClientexample.mac.myClientClient.myClientClientExtension and extension point com.apple.networkextension.packet-tunnel
default 12:33:36.813142+0200 nesessionmanager NESMVPNSession[Primary Tunnel:myClient example - myname_mfa.mynameaccount:2A6C1B7D-19E8-4EF7-8872-C1D0F8899A17:(null)]: Matched no on demand rule
default 12:33:36.784619+0200 myClientClient vpnStatusDidChange: Connecting
default 12:33:36.784729+0200 myClientClient display Connecting
default 12:33:36.813445+0200 nesessionmanager NESMVPNSession[Primary Tunnel:myClient example - myname_mfa.mynameaccount:2A6C1B7D-19E8-4EF7-8872-C1D0F8899A17:(null)]: Matched on demand rule
action = connect
interfaceTypeMatch = any
And after that there is a very big amount of
"Received a start command from" and "Skip a start command from " (and I copied only part of the log), but the VPN stays at the 'connecting' phase.
Any idea what's causing it?
Can it happen also on the production version of my app? I never reproduced it at the Store version, but it's not always reproduces anyway..