Network connections send and receive data using transport and security protocols.

Network Documentation

Pinned Posts

Posts under Network tag

336 Posts
Sort by:
Post not yet marked as solved
1 Replies
5.8k Views
We have confirmed that there is a server certificate revoke check by OCSP in iOS. We have some question about detail of this process.Q1. There is no request to OCSP Responder from iPhone when My Apps calls SecTrustEvaluate what using policy kSecRevokationOCSPMethod while executing URLSession:didReceiveChallenge on iPhone. Is it because of I got the answer form “the caches” which has been saved in iPhone before ?Q2. If Q1 is Yes , Could you tell me the timing of accessing to OCSP Responder in iOS? (Is it related to the App, or it is automatic updating in iOS?)Q3. If Q1 is Yes, How does it determine the expiration date of its caches? (Is there any information about next Update in the response from OCSP ?)Q4.When the iOS application using the UIWebview performs HTTPS access, In the case of redirect server is revoked ,does application check the OCSP responder whether it has been revoked or notEvaluation Environmnet1)Device Version:9.1(13B143) Carrier:docomo22.1 Model:MKU12J/A2)Networkonly Wifi access (without using SIM)
Posted
by
Post not yet marked as solved
0 Replies
41k Views
In 2016 Apple announced that, starting June 1, 2016, all apps submitted to the App Store must support IPv6-only networking (see this developer news article). If you have specific follow-up questions about this policy, please feel free to post them to DevForums using the Network tag. Alternatively, if you want private, one-to-one help, you can open a DTS tech support incident. At the end of this post you’ll find answers to some of the frequently asked questions about this announcement. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = "eskimo" + "1" + "@" + "apple.com" #1 — What’s the best way to check that my app works in an IPv6-only environment? You should test your app on an IPv6-only network. If you don’t have one handy, you can set up a test network by following the instructions in the Test for IPv6 DNS64/NAT64 Compatibility Regularly section of the Networking Overview. IMPORTANT If you’re testing with a WWAN-capable device, make sure to turn off WWAN before running your test. That ensures that your device is actually using the IPv6-only Wi-Fi. Note You can turn off WWAN using Settings > Cellular > Cellular Data (for English localisations outside of North America this is Settings > Mobile Data > Mobile Data). #2 — Do I need to remove all references to IPv4-only constructs (things like gethostbyname) from my app? No. It’s fine for your app to reference, and even use, IPv4-only constructs as long as it behaves correctly in an IPv6-only environment. IMPORTANT In our experience it is easier to adopt address-family agnostic APIs than to maintain separate code paths for IPv4 and IPv6, so we encourage you to do that. #3 — Will I need to update my server? That depends on where your server is running: If you have a server running on the wider Internet, the answer is no. Your server will be accessible to IPv6-only devices via DNS64/NAT64. You should update your server to support IPv6 as a matter of course, but that’s something you can do in your own time. If you have a server embedded within your iOS app (for example, a web server that allows users to transfer files to and from your app), you should make sure it works well in an IPv6-only environment. #4 — My app relies on the system’s ability to synthesise an IPv6 address from an IPv4 address. What should I do on older systems? As described in Use System APIs to Synthesize IPv6 Addresses, starting with iOS 9.2 and OS X 10.11.2 you can use getaddrinfo to synthesise an IPv6 address from an IPv4 address. Your app will be tested on a device running the latest released version of iOS, so you can assume that this support is present. WARNING Synthesising IPv6 addresses yourself is not easy. Specifically, it is not safe to form an IPv6 address by combining an IPv4 address with the Well-Known Prefix (64:ff9b::/96). This may work in some NAT64 networks but it is not a general solution to the problem. If you need to synthesise IPv6 addresses, use getaddrinfo on modern systems or see this post [1] for more background to this issue. [1] Sadly, I was unable to find the new destination for this link, at least in the time that I had available to work on it today. If you have any ideas as to what it should be, please get in touch. #5 — My app communicates with a local network-based accessory which requires IPv4 infrastructure. How can I meet this requirement? We strongly recommend that you modify your accessory to work on an IPv6-only network. There are two approaches you can take: Have the accessory support IPv6 Have the accessory support IPv4 link-local addressing (RFC 3927) Either option will allow your app to communicate with your accessory when both devices are placed on an IPv6-only network. If your accessory supports neither of these options, and it’s not possible for you to revise the accessory to do so, your accessory is fundamentally incompatible with the requirement to support IPv6. Please let App Review know about this when you submit your app. This is not grounds for rejection. The above only applies to your app’s communication with your accessory on the local network. Other aspects of your app are expected to work in an IPv6-only environment. Specifically, if your app has a way to talk to an accessory across the wider Internet, it must be willing to do that over IPv6. This will work via DNS64/NAT64 in the same way as your communication with any other IPv4-only server. #6 — App Review rejected my app, apparently for IPv6 compatibility problems. How can I investigate this? The IPv6 and App Review post discusses some of the more common reasons for why your app might encounter networking problems during review. Revision History 2024-02-06 Fixed some broken links. Fixed the formatting. Made other minor editorial changes. 2019-01-29 Refreshed various links. Made other minor editoral changes. 2016-06-23 Added FAQ #6. 2016-06-22 Added a discussion of the Well-Known Prefix to FAQ #4. 2016-05-31 Added FAQ #5. 2016-05-18 Added this change history. Added FAQ #4. Updated FAQ #1 to clarify the term WWAN and explicitly describe how to disable WWAN. 2016-05-17 Adding FAQs #1, #2 and #3. 2016-05-05 First posted.
Posted
by
Post not yet marked as solved
4 Replies
3.1k Views
If I make a request for a file with the "Range" header specified using iOS's URLSession then it will correctly give me this range. However, if I then request the same file without a "Range" header, I receive the same response as the ranged request. This is the case even if I request a different byte range on the same file.Here's an example:let url = "http://qthttp.apple.com.edgesuite.net/1010qwoeiuryfg/3340/33409.ts" let session = URLSession.shared let u = URL(string:url)! var request = URLRequest(url: u) request.addValue("bytes=10-19", forHTTPHeaderField: "Range") session.dataTask(with: request) {(data, response, error) in let response = response as! HTTPURLResponse print("Ranged with response: \(response.statusCode) \(response.allHeaderFields)") var request = URLRequest(url: u) request.addValue("bytes=20-49", forHTTPHeaderField: "Range") session.dataTask(with: request) {(data, response, error) in let response = response as! HTTPURLResponse print("Full request with response: \(response.statusCode) \(response.allHeaderFields)") }.resume() }.resume()I'd like to be able to request a range and then another range later, on the same file. Is there any way to do this without turning off local caching completely?
Posted
by
Post not yet marked as solved
0 Replies
6.3k Views
Transport Layer Security (TLS) is the most important security protocol on the Internet today. Most notably, TLS puts the S into HTTPS, adding security to the otherwise insecure HTTP protocol. IMPORTANT TLS is the successor to the Secure Sockets Layer (SSL) protocol. SSL is no longer considered secure and it’s now rarely used in practice, although many folks still say SSL when they mean TLS. TLS is a complex protocol. Much of that complexity is hidden from app developers but there are places where it’s important to understand specific details of the protocol in order to meet your requirements. This post explains the fundamentals of TLS, concentrating on the issues that most often confuse app developers. Note If you’re working on TLS in the local environment, for example, to talk to a Wi-Fi based accessory, see TLS For Accessory Developers. Server Certificates For standard TLS to work the server must have a digital identity, that is, the combination of a certificate and the private key matching the public key embedded in that certificate. TLS Crypto Magic™ ensures that: The client gets a copy of the server’s certificate. The client knows that the server holds the private key matching the public key in that certificate. In a typical TLS handshake the server passes the client a list of certificates, where item 0 is the server’s certificate (the leaf certificate), item N is (optionally) the certificate of the certificate authority that ultimately issued that certificate (the root certificate), and items 1 through N-1 are any intermediate certificates required to build a cryptographic chain of trust from 0 to N. Note The cryptographic chain of trust is established by means of digital signatures. Certificate X in the chain is issued by certificate X+1. The owner of certificate X+1 uses their private key to digitally sign certificate X. The client verifies this signature using the public key embedded in certificate X+1. Eventually this chain terminates in a trusted anchor, that is, a certificate that the client trusts by default. Typically this anchor is a self-signed root certificate from a certificate authority. Note Item N is optional for reasons I’ll explain below. Also, the list of intermediate certificates may be empty (in the case where the root certificate directly issued the leaf certificate) but that’s uncommon for servers in the real world. Once the client gets the server’s certificate, it evaluates trust on that certificate to confirm that it’s talking to the right server. There are three levels of trust evaluation here: Basic X.509 trust evaluation checks that there’s a cryptographic chain of trust from the leaf through the intermediates to a trusted root certificate. The client has a set of trusted root certificates built in (these are from well-known certificate authorities, or CAs), and a site admin can add more via a configuration profile. This step also checks that none of the certificates have expired, and various other more technical criteria (like the Basic Constraints extension). Note This explains why the server does not have to include the root certificate in the list of certificates it passes to the client; the client has to have the root certificate installed if trust evaluation is to succeed. In addition, TLS trust evaluation (per RFC 2818) checks that the DNS name that you connected to matches the DNS name in the certificate. Specifically, the DNS name must be listed in the Subject Alternative Name extension. Note The Subject Alternative Name extension can also contain IP addresses, although that’s a much less well-trodden path. Also, historically it was common to accept DNS names in the Common Name element of the Subject but that is no longer the case on Apple platforms. App Transport Security (ATS) adds its own security checks. Basic X.509 and TLS trust evaluation are done for all TLS connections. ATS is only done on TLS connections made by URLSession and things layered on top URLSession (like WKWebView). In many situations you can override trust evaluation; for details, see Technote 2232 HTTPS Server Trust Evaluation). Such overrides can either tighten or loosen security. For example: You might tighten security by checking that the server certificate was issued by a specific CA. That way, if someone manages to convince a poorly-managed CA to issue them a certificate for your server, you can detect that and fail. You might loosen security by adding your own CA’s root certificate as a trusted anchor. IMPORTANT If you rely on loosened security you have to disable ATS. If you leave ATS enabled, it requires that the default server trust evaluation succeeds regardless of any customisations you do. Mutual TLS The previous section discusses server trust evaluation, which is required for all standard TLS connections. That process describes how the client decides whether to trust the server. Mutual TLS (mTLS) is the opposite of that, that is, it’s the process by which the server decides whether to trust the client. Note mTLS is commonly called client certificate authentication. I avoid that term because of the ongoing confusion between certificates and digital identities. While it’s true that, in mTLS, the server authenticates the client certificate, to set this up on the client you need a digital identity, not a certificate. mTLS authentication is optional. The server must request a certificate from the client and the client may choose to supply one or not (although if the server requests a certificate and the client doesn’t supply one it’s likely that the server will then fail the connection). At the TLS protocol level this works much like it does with the server certificate. For the client to provide this certificate it must apply a digital identity, known as the client identity, to the connection. TLS Crypto Magic™ assures the server that, if it gets a certificate from the client, the client holds the private key associated with that certificate. Where things diverge is in trust evaluation. Trust evaluation of the client certificate is done on the server, and the server uses its own rules to decided whether to trust a specific client certificate. For example: Some servers do basic X.509 trust evaluation and then check that the chain of trust leads to one specific root certificate; that is, a client is trusted if it holds a digital identity whose certificate was issued by a specific CA. Some servers just check the certificate against a list of known trusted client certificates. When the client sends its certificate to the server it actually sends a list of certificates, much as I’ve described above for the server’s certificates. In many cases the client only needs to send item 0, that is, its leaf certificate. That’s because: The server already has the intermediate certificates required to build a chain of trust from that leaf to its root. There’s no point sending the root, as I discussed above in the context of server trust evaluation. However, there are no hard and fast rules here; the server does its client trust evaluation using its own internal logic, and it’s possible that this logic might require the client to present intermediates, or indeed present the root certificate even though it’s typically redundant. If you have problems with this, you’ll have to ask the folks running the server to explain its requirements. Note If you need to send additional certificates to the server, pass them to the certificates parameter of the method you use to create your URLCredential (typically init(identity:certificates:persistence:)). One thing that bears repeating is that trust evaluation of the client certificate is done on the server, not the client. The client doesn’t care whether the client certificate is trusted or not. Rather, it simply passes that certificate the server and it’s up to the server to make that decision. When a server requests a certificate from the client, it may supply a list of acceptable certificate authorities [1]. Safari uses this to filter the list of client identities it presents to the user. If you are building an HTTPS server and find that Safari doesn’t show the expected client identity, make sure you have this configured correctly. If you’re building an iOS app and want to implement a filter like Safari’s, get this list using: The distinguishedNames property, if you’re using URLSession The sec_protocol_metadata_access_distinguished_names routine, if you’re using Network framework [1] See the certificate_authorities field in Section 7.4.4 of RFC 5246, and equivalent features in other TLS versions. Self-Signed Certificates Self-signed certificates are an ongoing source of problems with TLS. There’s only one unequivocally correct place to use a self-signed certificate: the trusted anchor provided by a certificate authority. One place where a self-signed certificate might make sense is in a local environment, that is, securing a connection between peers without any centralised infrastructure. However, depending on the specific circumstances there may be a better option. TLS For Accessory Developers discusses this topic in detail. Finally, it’s common for folks to use self-signed certificates for testing. I’m not a fan of that approach. Rather, I recommend the approach described in QA1948 HTTPS and Test Servers. For advice on how to set that up using just your Mac, see TN2326 Creating Certificates for TLS Testing. TLS Standards RFC 6101 The Secure Sockets Layer (SSL) Protocol Version 3.0 (historic) RFC 2246 The TLS Protocol Version 1.0 RFC 4346 The Transport Layer Security (TLS) Protocol Version 1.1 RFC 5246 The Transport Layer Security (TLS) Protocol Version 1.2 RFC 8446 The Transport Layer Security (TLS) Protocol Version 1.3 RFC 4347 Datagram Transport Layer Security RFC 6347 Datagram Transport Layer Security Version 1.2 RFC 9147 The Datagram Transport Layer Security (DTLS) Protocol Version 1.3 Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = "eskimo" + "1" + "@" + "apple.com" Revision History: 2024-03-19 Adopted the term mutual TLS in preference to client certificate authentication throughout, because the latter feeds into the ongoing certificate versus digital identity confusion. Defined the term client identity. Added the Self-Signed Certificates section. Made other minor editorial changes. 2023-02-28 Added an explanation mTLS acceptable certificate authorities. 2022-12-02 Added links to the DTLS RFCs. 2022-08-24 Added links to the TLS RFCs. Made other minor editorial changes. 2022-06-03 Added a link to TLS For Accessory Developers. 2021-02-26 Fixed the formatting. Clarified that ATS only applies to URLSession. Minor editorial changes. 2020-04-17 Updated the discussion of Subject Alternative Name to account for changes in the 2019 OS releases. Minor editorial updates. 2018-10-29 Minor editorial updates. 2016-11-11 First posted.
Posted
by
Post not yet marked as solved
0 Replies
21k Views
At WWDC 2015 Apple announced two major enhancements to the Network Extension framework: Network Extension providers — These are app extensions that let you insert your code at various points within the networking stack, including: Packet tunnels via NEPacketTunnelProvider App proxies via NEAppProxyProvider Content filters via NEFilterDataProvider and NEFilterControlProvider Hotspot Helper (NEHotspotHelper) — This allows you to create an app that assists the user in navigating a hotspot (a Wi-Fi network where the user must interact with the network in order to get access to the wider Internet). Originally, using any of these facilities required authorisation from Apple. Specifically, you had to apply for, and be granted access to, a managed capability. In Nov 2016 this policy changed for Network Extension providers. Any developer can now use the Network Extension provider capability like they would any other capability. There is one exception to this rule: Network Extension app push providers, introduced by iOS 14 in 2020, still requires that Apple authorise the use of a managed capability. To apply for that, follow the link in Local Push Connectivity. Also, the situation with Hotspot Helpers remains the same: Using a Hotspot Helper, requires that Apple authorise that use via a managed capability. To apply for that, follow the link in Hotspot Helper. IMPORTANT Pay attention to this quote from the documentation: NEHotspotHelper is only useful for hotspot integration. There are both technical and business restrictions that prevent it from being used for other tasks, such as accessory integration or Wi-Fi based location. The rest of this document answers some frequently asked questions about the Nov 2016 change. #1 — Has there been any change to the OS itself? No, this change only affects the process by which you get the capabilities you need in order to use existing Network Extension framework facilities. Previously these were managed capabilities, meaning their use was authorised by Apple. Now, except for app push providers and Hotspot Helper, you can enable the necessary capabilities using Xcode’s Signing & Capabilities editor or the Developer website. IMPORTANT Some Network Extension providers have other restrictions on their use. For example, a content filter can only be used on a supervised device. These restrictions are unchanged. See TN3134 Network Extension provider deployment for the details. #2 — How exactly do I enable the Network Extension provider capability? In the Signing & Capabilities editor, add the Network Extensions capability and then check the box that matches the provider you’re creating. In the Certificates, Identifiers & Profiles section of the Developer website, when you add or edit an App ID, you’ll see a new capability listed, Network Extensions. Enable that capability in your App ID and then regenerate the provisioning profiles based on that App ID. A newly generated profile will include the com.apple.developer.networking.networkextension entitlement in its allowlist; this is an array with an entry for each of the supported Network Extension providers. To confirm that this is present, dump the profile as shown below. $ security cms -D -i NETest.mobileprovision … <plist version="1.0"> <dict> … <key>Entitlements</key> <dict> <key>com.apple.developer.networking.networkextension</key> <array> <string>packet-tunnel-provider</string> <string>content-filter-provider</string> <string>app-proxy-provider</string> … and so on … </array> … </dict> … </dict> </plist> #3 — I normally use Xcode’s Signing & Capabilities editor to manage my entitlements. Do I have to use the Developer website for this? No. Xcode 11 and later support this capability in the Signing & Capabilities tab of the target editor (r. 28568128 ). #4 — Can I still use Xcode’s “Automatically manage signing” option? Yes. Once you modify your App ID to add the Network Extension provider capability, Xcode’s automatic code signing support will include the entitlement in the allowlist of any profiles that it generates based on that App ID. #5 — What should I do if I previously applied for the Network Extension provider managed capability and I’m still waiting for a reply? Consider your current application cancelled, and use the new process described above. #6 — What should I do if I previously applied for the Hotspot Helper managed capability and I’m still waiting for a reply? Apple will continue to process Hotspot Helper managed capability requests and respond to you in due course. #7 — What if I previously applied for both Network Extension provider and Hotspot Helper managed capabilities? Apple will ignore your request for the Network Extension provider managed capability and process it as if you’d only asked for the Hotspot Helper managed capability. #8 — On the Mac, can Developer ID apps host Network Extension providers? Yes, but there are some caveats: This only works on macOS 10.15 or later. Your Network Extension provider must be packaged as a system extension, not an app extension. You must use the *-systemextension values for the Network Extension entitlement (com.apple.developer.networking.networkextension). For more on this, see Exporting a Developer ID Network Extension. #9 — After moving to the new process, my app no longer has access to the com.apple.managed.vpn.shared keychain access group. How can I regain that access? Access to this keychain access group requires another managed capability. If you need that, please open a DTS tech support incident and we’ll take things from there. IMPORTANT This capability is only necessary if your VPN supports configuration via a configuration profile and needs to access credentials from that profile (as discussed in the Profile Configuration section of the NETunnelProviderManager Reference). Many VPN apps don’t need this facility. Opening a DTS tech support incident (TSI) will consume a TSI asset. However, as this is not a technical issue but an administrative one, we’ll assign a replacement TSI asset back to your account. If you were previously granted the Network Extension managed capability (via the process in place before Nov 2016), make sure you mention that; restoring your access to the com.apple.managed.vpn.shared keychain access group should be straightforward in that case. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = "eskimo" + "1" + "@" + "apple.com" Revision History 2023-01-11 Added a discussion of Network Extension app push providers. Added a link to Exporting a Developer ID Network Extension. Added a link to TN3134. Made significant editorial changes. 2020-02-27 Fixed the formatting. Updated FAQ#3. Made minor editorial changes. 2020-02-16 Updated FAQ#8 to account for recent changes. Updated FAQ#3 to account for recent Xcode changes. Made other editorial changes. 2016-01-25 Added FAQ#9. 2016-01-6 Added FAQ#8. 2016-11-11 Added FAQ#5, FAQ#6 and FAQ#7. 2016-11-11 First posted.
Posted
by
Post marked as solved
3 Replies
4.3k Views
Hi,I would like to ask one question in regards to HTTP status code 403 request with client certificate authentication challenge.So, I was implementing a solution that requires mutusl TLS which will set the delegate responded to the client identity authentication challenge, and experienced the issue when the request fails with 403, the iOS SDK returns the error NSURLErrorClientCertificateRequired rather than the error that was actually returned from the server side.I found the thread in the forum that explains the exactly the same issue, but would like to clarify few more things here.From my experiment, what I found is that this behaviour only happens for the first 5 or 10 minutes of NSURLSession's session.For example, I will get the NSURLErrorClientCertificateRequired only for the first five or ten minutes, and after that, I am receiving the expected error message from the server side.This reminds me of TLS caching issue back in iOS 9 or below with NSURLConnection and NSURLSession (which resolves by re-contructing NSURLSession object); however, in this case, it is not simple to reconstruct the NSURLSession object based on the response from the server side.Was this officially reported or known to Apple as a bug? or is this kind of expected behaviour? Is there any official statement from Apple acknowledging this issue (like known-issues)? Can you help me direct to places where I can find this information, if any?Thanks,
Posted
by
Post not yet marked as solved
0 Replies
4.1k Views
Questions about FTP crop up from time-to-time here on DevForums. In most cases I write a general “don’t use FTP” response, but I don’t have time to go into all the details. I’ve created this post as a place to collect all of those details, so I can reference them in other threads. IMPORTANT Apple’s official position on FTP is: All our FTP APIs have been deprecated, and you should avoid using deprecated APIs. Apple has been slowly removing FTP support from the user-facing parts of our system. The most recent example of this is that we removed the ftp command-line tool in macOS 10.13. You should avoid the FTP protocol and look to adopt more modern alternatives. The rest of this post is an informational explanation of the overall FTP picture. This post is locked so I can keep it focused. If you have questions or comments, please do create a new thread with the Network tag and I’ll respond there. Don’t Use FTP FTP is a very old and very crufty protocol. Certain things that seem obvious to us now — like being able to create a GUI client that reliably shows a directory listing in a platform-independent manner — are not possible to do in FTP. However, by far the biggest problem with FTP is that it provides no security [1]. Specifically, the FTP protocol: Provides no on-the-wire privacy, so anyone can see the data you transfer Provides no client-authenticates-server authentication, so you have no idea whether you’re talking to the right server Provides no data integrity, allowing an attacker to munge your data in transit Transfers user names and passwords in the clear Using FTP for anonymous downloads may be acceptable (see the note below) but most other uses of FTP are completely inappropriate for the modern Internet. IMPORTANT You should only use FTP for anonymous downloads if you have an independent way to check the integrity of the data you’ve downloaded. For example, if you’re downloading a software update, you could use code signing to check its integrity. If you don’t check the integrity of the data you’ve downloaded, an attacker could substitute a malicious download instead. This would be especially bad in, say, the software update case. These fundamental problems with the FTP protocol mean that it’s not a priority for Apple. This is reflected in the available APIs, which is the subject of the next section. FTP APIs Apple provides two FTP APIs: All Apple platforms provide FTP downloads via NSURLSession Most Apple platforms (everything except watchOS) support CFFTPStream, which allows for directory listings, downloads, uploads, and directory creation. All of these FTP APIs are now deprecated: NSURLSession was deprecated for the purposes of FTP in the 2022 SDKs (macOS 13, {i{,Pad},tv}OS 16, watchOS 9) [2]. CFFTPStream was deprecated in the 2016 SDKs (macOS 10.11, {i{,Pad},tv}OS 9). CFFTPStream still works about as well as it ever did, which is not particularly well. Specifically: There is at least one known crashing bug (r. 35745763), albeit one that occurs quite infrequently. There are clear implementation limitations — like the fact that CFFTPCreateParsedResourceListing assumes a MacRoman text encoding (r. 7420589) — that will not be fixed. If you’re looking for an example of how to use these APIs, check out SimpleFTPSample. Note This sample has not been updated since 2013 and is unlikely to ever be updated given Apple’s position on FTP. The FTP support in NSURLSession has significant limitations: NSURLSession only supports FTP downloads; there is no support for uploads or any other FTP operations NSURLSession does not support resumable FTP downloads [3] NSURLSession background sessions only support HTTP and HTTPS, so you can’t run FTP downloads in the background on iOS If Apple’s FTP APIs are insufficient for your needs, you’ll need to write or acquire your own FTP library. Before you do that, however, consider switching to an alternative protocol. After all, if you’re going to go to the trouble of importing a large FTP library into your code base, you might as well import a library for a better protocol. The next section discusses some options in this space. Alternative Protocols There are numerous better alternatives to FTP: HTTPS is by far the best alternative to FTP, offering good security, good APIs on Apple platforms, good server support, and good network compatibility. Implementing traditional FTP operations over HTTPS can be a bit tricky. One possible way forward is to enable DAV extensions on the server. FTPS is FTP over TLS (aka SSL). While FTPS adds security to the protocol, which is very important, it still inherits many of FTP’s other problems. Personally I try to avoid this protocol. SFTP is a file transfer protocol that’s completely unrelated to FTP. It runs over SSH, making it a great alternative in many of the ad hoc setups that traditionally use FTP. Apple does not have an API for either FTPS or SFTP, although on macOS you may be able to make some headway by invoking the sftp command-line tool. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = "eskimo" + "1" + "@" + "apple.com" [1] In another thread someone asked me about FTP’s other problems, those not related to security, so let’s talk about that. One of FTP’s implicit design goals was to provide cross-platform support that exposes the target platform. You can think of FTP as being kinda like telnet. When you telnet from Unix to VMS, it doesn’t aim to abstract away VMS commands, so that you can type Unix commands at the VMS prompt. Rather, you’re expected to run VMS commands. FTP is (a bit) like that. This choice made sense back when the FTP protocol was invented. Folks were expecting to use FTP via a command-line client, so there was a human in the loop. If they ran a command and it produced VMS-like output, that was fine because they knew that they were FTPing into a VMS machine. However, most users today are using GUI clients, and this design choice makes it very hard to create a general GUI client for FTP. Let’s consider the simple problem of getting the contents of a directory. When you send an FTP LIST command, the server would historically run the platform native directory list command and pipe the results back to you. To create a GUI client you have to parse that data to extract the file names. Doing that is a serious challenge. Indeed, just the first step, working out the text encoding, is a challenge. Many FTP servers use UTF-8, but some use ISO-Latin-1, some use other standard encodings, some use Windows code pages, and so on. I say “historically” above because there have been various efforts to standardise this stuff, both in the RFCs and in individual server implementations. However, if you’re building a general client you can’t rely on these efforts. After all, the reason why folks continue to use FTP is because of it widespread support. [2] To quote the macOS 13 Ventura Release Notes: FTP is deprecated for URLSession and related APIs. Please adopt modern secure networking protocols such as HTTPS. (92623659) [3] Although you can implement resumable downloads using the lower-level CFFTPStream API, courtesy of the kCFStreamPropertyFTPFileTransferOffset property. Revision History 2024-04-15 Added a footnote about FTP’s other problems. Made other minor editorial changes. 2022-08-09 Noted that the FTP support in NSURLSession is now deprecated. Made other minor editorial changes. 2021-04-06 Fixed the formatting. Fixed some links. 2018-02-23 First posted.
Posted
by
Post marked as solved
25 Replies
28k Views
Hey Apple devs,Has anyone encountered ping spikes on macOS when using WiFi? When you run a constant ping, it looks like this…64 bytes from 192.168.0.30: icmp_seq=502 ttl=128 time=1.443 ms64 bytes from 192.168.0.30: icmp_seq=503 ttl=128 time=3.007 ms64 bytes from 192.168.0.30: icmp_seq=504 ttl=128 time=1.684 ms64 bytes from 192.168.0.30: icmp_seq=505 ttl=128 time=186.861 ms64 bytes from 192.168.0.30: icmp_seq=506 ttl=128 time=69.545 ms64 bytes from 192.168.0.30: icmp_seq=507 ttl=128 time=141.434 ms64 bytes from 192.168.0.30: icmp_seq=508 ttl=128 time=24.043 ms64 bytes from 192.168.0.30: icmp_seq=509 ttl=128 time=2.961 ms64 bytes from 192.168.0.30: icmp_seq=510 ttl=128 time=1.827 ms64 bytes from 192.168.0.30: icmp_seq=511 ttl=128 time=1.171 msSeems to happen reliably when you open the WiFi menu bar on High Sierra. Other apps can cause this too.I think others are seeing this issue too (especially gamers):https://apple.stackexchange.com/questions/263638/macbook-pro-experiencing-ping-spikes-to-local-routerAs well as games, real time network apps like Synergy suffer too:https://symless.com/help/mac-wifi-lagCheers,Nick
Posted
by
Post not yet marked as solved
20 Replies
22k Views
I'm trying to spoof the MAC address of a MBP 15" 2018 running High Sierra 10.13.6 in order to validate network filtering but I'm unable to change it using ifconfig."sudo ifconfig en0 ether &lt;new mac address&gt;"Does anyone knows if there is a hardware/software limitation to do it on the new MacBooks?
Posted
by
Post not yet marked as solved
4 Replies
1.6k Views
Hallo everyone! I'm working on a WatchOS app uploading files to servers using URLSession. It works fine when the paired phone is there. However, if the paired iphone is not reachable (e.g. switch-off, out-of-reach, etc.), AND the watch is connected to Wifi, the URLSession fails to post messages, and times out.According to Apple documentation, WatchOS Wifi should work stand-alone.https://developer.apple.com/documentation/watchkit/keeping_your_watchos_app_s_content_up_to_date/testing_watchos_networking"Connecting to a known network. If the watch cannot connect to a paired iPhone, but it can connect to a known WiFi network (a network that the user has previously logged into with their phone), then the request is sent using the WiFi network. When connected to a known network, the control center shows the WiFi network in the upper left corner."I am struggling with this. Does anyone have successful experience, using URLSession and making WatchOS Wifi only connections in the App? Thanks a lot in advance!Zhaorui
Posted
by
Post not yet marked as solved
13 Replies
12k Views
Hi,We have a need in our Swift app for using a HTTP proxy with WKWebView. We want to route all HTTP(S) traffic through a proxy running Privoxy, which strips the http(s) traffic of tracking scripts and ads (for HTTPS traffic we obviously cannot see the content and strip the ads, but we can still block the requests going to hostnames that are known for serving ads). That is basically our product to our costumers. Anonymous (through proxy), ad and tracking free browsing, where no one is monitoring what you are buying or browsing with the purpose of profiling you and selling the information about you to others.With the now deprecated UIWebview, we were able to setup a HTTP proxy through the NSUrlProtocol, but since its deprecated now, continouing using it seems like a risky idea in anything but the short term.We have not found any way, by which we can setup a HTTP proxy in the WKWebView, since it seems to be doing the networking out-of-process of the app... Sources like this post on this forum seems to back this up: https://forums.developer.apple.com/thread/74572.However, Ssome sources seems to indicate that WkWebView was made more user-friendly with IOS 11 and IOS 12 - which is after the above post, so maybe it is possible now. As said, we have tried without luck recently, but maybe we are missing something?We hope someone can help or otherwise just give us some clarity, as the core part of our product depends on this feature, so any help and/or clarity is appreciated.NB:We have considered other options such as using a VPN to send all our data through our own servers. This requires that we change our full infrastructure setup though. And it seems that there is no split-tunneling options in IOS (on non-managed IOS), so if we use the VPN approach, our VPN connection (meant just for some casual browser surfing) will become a general VPN connection on the device. That means we would have to carry the full load of the users' network usage suddenly, which would likely force us to triple our monthly subscription fee to be rentable...Hope to get an answer, and sorry for the slightly long post! (Hopefully it showed we have done our homework and are not asking you to do it for us atleast!).Best,Jonas
Posted
by
Post not yet marked as solved
3 Replies
2.0k Views
Currently I see methods to get the name, index, and type of nw_interface_t objects. Is there a way to get the IP addresses attached to that interface?I tried nw_path's nw_path_copy_effective_local_endpoint inside of a nw_path_monitor callback, but it always returns null.
Posted
by
Post marked as solved
2 Replies
2.3k Views
I'm struggling to use NWListener and NWConnection on the same port.I have a simple task requires that I send out a UDP datagram to the broadcast address, and expect to receive replies on the port which sent the datagram. In Blue Sockets, I can create a socket, send out the broadcast message and listen and accept connections on the same socket.In wireshark the exchange looks like:10.0.0.123 255.255.255.255 UDP 71 62003 -&gt; 9000 Len=29 10.0.0.202 10.0.0.123 UDP 1060 9000 -&gt; 62003 Len=101However after hours of experimentation in a swift playground, I am not able to create an NWListener and an NWConnection on the same socket.Here are the salient pieces of code:let udpListener = try! NWListener(using: .udp) ... setup and start listener let broadcast: NWEndpoint.Host = "255.255.255.255" let portUDP: NWEndpoint.Port = 9000 let localPort : NWEndpoint.Port = udpListener!.port! let localEndpoint = NWEndpoint.hostPort(host: "10.0.0.123", port: localPort) let parameters = NWParameters.udp parameters.requiredLocalEndpoint = localEndpoint let connection = NWConnection(host: broadcast, port: portUDP, using: parameters)However creating the NWConnection on the same port as the NWListener gives an error that the port is in use. I've tried the reverse, createing the connection on a known port, closing it and starting a listener immediately affterwards on that same port, but that also results in an error.How can I implement this very simple protocol using the Network API ? Are there some options I need to set ?Thanks for any help.Guy
Posted
by
Post marked as solved
7 Replies
832 Views
Hello,I have a local WebSocket server running inside an iOS app on iOS 13+. I'm using Swift NIO Transport Services for the server.I'm using NWProtocolTLS.Options from Network framework to specify TLS options for my server.I am providing my server as an XCFramework and want to let users to be able to specify different parameters when launching the server.For specifiying the TLS supported version, everything is working fine by using :public func sec_protocol_options_set_max_tls_protocol_version(_ options: sec_protocol_options_t, _ version: tls_protocol_version_t) public func sec_protocol_options_set_min_tls_protocol_version(_ options: sec_protocol_options_t, _ version: tls_protocol_version_t)But I also want to be able to specify some cipher suites. I saw that I can use :public func sec_protocol_options_append_tls_ciphersuite(_ options: sec_protocol_options_t, _ ciphersuite: tls_ciphersuite_t)But it seems that some cipher suites are enabled by default and I can't restrict the cipher suites just to the ones I want, I can just append others.NWProtocolTLS.Options class has an init() function which states "Initializes a default set of TLS connection options" on Apple documentation.So my question is, is there a way to know what TLS parameters this initialization does ? Especially the list of cipher suites enabled by default ? Because I can't find any information about it from my research. I used a tool to test handshake with my server to discover the cipher suites supported and enabled by default but I don't think it is a good way to be sure about this information.And is there a way to specify only cipher suites I want to be supported by my server by using NWProtocolTLS.Options ?Thank you in advance,Christophe
Posted
by
Post not yet marked as solved
3 Replies
857 Views
I've tried several functions for executing a proxy autoconfiguration script to determine the best proxy to use to retrieve a specified URL CFNetworkCopyProxiesForAutoConfigurationScript CFNetworkExecuteProxyAutoConfigurationURL CFNetworkExecuteProxyAutoConfigurationScript And they all seems to ignore HTTPS keyword in PAC file function FindProxyForURL(url, host) { &#9;&#9;return "HTTPS ...";&#9;&#9; } That seems to be only way to use HTTPS proxy. Can someone please confirm this?
Posted
by
Post marked as Apple Recommended
23k Views
Greetings All I’ve received a number of requests for help from folks who’ve been granted access to the multicast entitlement (com.apple.developer.networking.multicast) but are having problems actually enabling it in their project. I wrote up some instructions for doing this and I’m sharing them here for the benefit of all. There are actually two processes involved here: In the new process you add the Multicast Networking additional capability to your App ID and then create a provisioning profile based on that. In the old process you add this additional capability to your provisioning profile in an Additional Entitlements step. Each process is covered in a follow-up post below. Note Almost everyone should be using the new process, but I’ve left the old process post in place just in case there’s still a few old process folks around. It also makes a good reference for folks who are using different additional capabilities, ones that require the old process. If you have follow-up questions about this, please put them in a new thread here on DevForums and tag it with both Network and Entitlements. Finally, since I wrote these instructions Apple has published official documentation about this process, in the form of Developer Account Help > Reference > Provisioning with managed capabilities. IMPORTANT Xcode 15 beta supports additional capabilities in the Signing & Capabilities editor. For the details, see the discussion of 27253063 in the Xcode 15 Beta Release Notes. Hopefully this will make this document largely obsolete (-: Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = "eskimo" + "1" + "@" + "apple.com" Version History: 2022-06-12 Added a callout to the change in Xcode 15 beta. Fixed a broken link. Made other minor editorial changes. 2022-01-27 Updated the New Process section with some Mac-specific notes. Added a link to the official documentation for this process. 2021-05-11 Renamed everything to better match the terms used by the developer web site for the new process. 2021-03-17 Clarified why I’ve left the Old Process post in place. Rewrote the New Process post to use automatic code signing. 2020-10-08 Expanded to cover the new process. 2020-10-06 Made minor tweaks to the No Additional Entitlements Page section. 2020-09-30 First posted.
Posted
by
Post not yet marked as solved
0 Replies
14k Views
I regularly get asked questions about local network privacy. This is my attempt to collect together the answers for the benefit of all. Before you delve into the details, familiarise yourself with the basics by watching WWDC 2020 Session 10110 Support local network privacy in your app. Share and Enjoy — Quinn “The Eskimo!” @ Developer Technical Support @ Apple let myEmail = "eskimo" + "1" + "@" + "apple.com" Local Network Privacy FAQ With local network privacy, any app that wants to interact with devices on your network must ask for permission the first time that it attempts that access. Local network privacy is implemented on iOS, iPadOS, and the current visionOS beta. It’s not implemented on other platforms, including macOS and tvOS. Some common questions about local network privacy are: FAQ-1 What is a local network? FAQ-2 What operations require local network access? FAQ-3 What operations require the multicast entitlement? FAQ-4 Do I need the multicast entitlement? FAQ-5 I’ve been granted the multicast entitlement; how do I enable it? FAQ-6 Can App Clips access the local network? FAQ-7 How does local network privacy work with app extensions? FAQ-8 How do I explicitly trigger the local network privacy alert? FAQ-9 How do I tell whether I’ve been granted local network access? FAQ-10 How do I use the unsatisfied reason property? FAQ-11 Do I need a local network usage description property? FAQ-12 Can I test on the simulator? FAQ-13 Once my app has displayed the local network privacy alert, how can I reset its state so that it shows again? FAQ-14 How do I map my Multipeer Connectivity service type to an entry in the Bonjour services property? FAQ-15 My app presents the local network privacy alert unexpectedly. Is there a way to track down the cause? FAQ-16 On a small fraction of devices my app fails to present the local network privacy alert. What’s going on? FAQ-17 Why does local network privacy get confused when I install two variants of my app? FAQ-18 Can my app trigger the local network privacy alert when the device is on WWAN? Revision History 2023-10-31 Fixed a bug in the top-level FAQ that mistakenly removed some recent changes. Added FAQ-18. 2023-10-19 Added a preamble to clarify that local network privacy is only relevant on specific platforms. 2023-09-14 Added FAQ-17. 2023-08-29 Added FAQ-16. 2023-03-13 Added connecting a UDP socket to FAQ-2. 2022-10-04 Added screen shots to FAQ-11. 2022-09-22 Fixed the pointer from FAQ-9 to FAQ-10. 2022-09-19 Updated FAQ-3 to cover iOS 16 changes. Made other minor editorial changes. 2020-11-12 Made a minor tweak to FAQ-9. 2020-10-17 Added FAQ-15. Added a second suggestion to FAQ-13. 2020-10-16 First posted.
Posted
by
Post not yet marked as solved
1 Replies
2.5k Views
This post is part of the Local Network Privacy FAQ - https://developer.apple.com/forums/thread/663858. My app presents the local network privacy alert unexpectedly. Is there a way to track down the cause? If the alert is correlated with something you do in your app then you can step through your code to see what triggers it. However, in some cases this won’t help. For example, some third-party libraries automatically run code in your app that triggers the local network privacy alert. One option here is to start removing any third-party libraries from your app until you figure out which one is triggering it, and then raise this issue with the library’s vendor. If you get completely stuck then start a new thread here on DevForums - https://developer.apple.com/forums/ and I’ll try to help out there. Make sure to tag your thread with one of the standard networking tags (Bonjour, CFNetwork, or Network). Back to the FAQ - https://developer.apple.com/forums/thread/663858
Posted
by
Post not yet marked as solved
10 Replies
2.5k Views
 I have the following code to force the connectivity over cellular and it works perfectly &#9; let tcpOptions = NWProtocolTCP.Options()     tcpOptions.connectionTimeout = 5     var tlsOptions: NWProtocolTLS.Options?     var port = 80     if (url.scheme!.starts(with:"https")) {       port = 443       tlsOptions = .init()     }     /*force network connection to cellular only*/     let params = NWParameters(tls: tlsOptions , tcp: tcpOptions)     params.requiredInterfaceType = .cellular     params.prohibitExpensivePaths = false     params.prohibitedInterfaceTypes = [.wifi]     /* create network connection */     connection = NWConnection(host: NWEndpoint.Host(url.host!), port: NWEndpoint.Port(rawValue: UInt16(port))!, using: params) Now I'm looking to force the connection to use ipv4 (even if the phone has an ipv6 available) because the targeted server has a broken ipv6 support and I don't have control over it (it belongs to a mobile operator) Any idea? E
Posted
by