Get Process ID (pid) from NEPacketTunnelFlow & sourceAppAuditToken (Always nil)

I implemented a per-app vpn with packetTunnelProvider on MacOS, fully functional. I would like to get the PID from sourceAppAuditToken but it is always nil. This is the code:

self.packetFlow.readPacketObjects { packets in
            for packet in packets {                
                if let auditToken = packet.metadata!.sourceAppAuditToken {
                  log.debug("ok")
                } else {
                  log.debug("No audit Token")
                }
            }
        }

I read a lot of answer about this problem but all solved on NEFilterFlow and they don't actually work on PacketTunnelFlow

Based on the presence of the force unwrap I suspect that packet.metadata is not nil and it’s sourceAppAuditToken that’s nil. Is that correct?

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Get Process ID (pid) from NEPacketTunnelFlow & sourceAppAuditToken (Always nil)
 
 
Q