View in English

  • Apple Developer
    • Get Started

    Explore Get Started

    • Overview
    • Learn
    • Apple Developer Program

    Stay Updated

    • Latest News
    • Hello Developer
    • Platforms

    Explore Platforms

    • Apple Platforms
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store

    Featured

    • Design
    • Distribution
    • Games
    • Accessories
    • Web
    • Home
    • CarPlay
    • Technologies

    Explore Technologies

    • Overview
    • Xcode
    • Swift
    • SwiftUI

    Featured

    • Accessibility
    • App Intents
    • Apple Intelligence
    • Games
    • Machine Learning & AI
    • Security
    • Xcode Cloud
    • Community

    Explore Community

    • Overview
    • Meet with Apple events
    • Community-driven events
    • Developer Forums
    • Open Source

    Featured

    • WWDC
    • Swift Student Challenge
    • Developer Stories
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Centers
    • Documentation

    Explore Documentation

    • Documentation Library
    • Technology Overviews
    • Sample Code
    • Human Interface Guidelines
    • Videos

    Release Notes

    • Featured Updates
    • iOS
    • iPadOS
    • macOS
    • watchOS
    • visionOS
    • tvOS
    • Xcode
    • Downloads

    Explore Downloads

    • All Downloads
    • Operating Systems
    • Applications
    • Design Resources

    Featured

    • Xcode
    • TestFlight
    • Fonts
    • SF Symbols
    • Icon Composer
    • Support

    Explore Support

    • Overview
    • Help Guides
    • Developer Forums
    • Feedback Assistant
    • Contact Us

    Featured

    • Account Help
    • App Review Guidelines
    • App Store Connect Help
    • Upcoming Requirements
    • Agreements and Guidelines
    • System Status
  • Quick Links

    • Events
    • News
    • Forums
    • Sample Code
    • Videos
 

Vídeos

Abrir menu Fechar menu
  • Coleções
  • Todos os vídeos
  • Sobre

Mais vídeos

  • Sobre
  • Código
  • Enable encrypted DNS

    When people access the web within your app, their privacy is paramount. Safeguard that information by leveraging encrypted DNS across our platforms to deliver private and secure connectivity within your app. Discover how you can use system DNS settings to connect to encrypted servers or enable encrypted DNS within an app using standard networking APIs.

    Enabling encrypted DNS is yet another way your app can help preserve privacy for your customers and provide them with a better and more secure experience.

    Recursos

      • Vídeo HD
      • Vídeo SD

    Vídeos relacionados

    WWDC23

    • What’s new in privacy

    WWDC22

    • Improve DNS security for apps and servers

    WWDC20

    • Boost performance and security with modern networking
    • Build trust through better privacy
  • Buscar neste vídeo...
    • 4:16 - Create a DNS configuration

      // Create a DNS configuration
      
      import NetworkExtension
      
      NEDNSSettingsManager.shared().loadFromPreferences { loadError in
          if let loadError = loadError {
              // ...handle error...
              return
          }
          let dohSettings = NEDNSOverHTTPSSettings(servers: [ "2001:db8::2" ])
          dohSettings.serverURL = URL(string: "https://dnsserver.example.net/dns-query")
          NEDNSSettingsManager.shared().dnsSettings = dohSettings
          NEDNSSettingsManager.shared().saveToPreferences { saveError in
              if let saveError = saveError {
                  // ...handle error...
                  return
              }
          }
      }
    • 6:40 - Apply network rules

      // Apply network rules
      
      let workWiFi = NEOnDemandRuleEvaluateConnection()
      workWiFi.interfaceTypeMatch = .wiFi
      workWiFi.ssidMatch = ["MyWorkWiFi"]
      workWiFi.connectionRules =
          [ NEEvaluateConnectionRule(matchDomains: ["enterprise.example.net"],
                                     andAction: .neverConnect) ]
      
      let disableOnCell = NEOnDemandRuleDisconnect()
      disableOnCell.interfaceTypeMatch = .cellular
      
      let enableByDefault = NEOnDemandRuleConnect()
      
      NEDNSSettingsManager.shared().onDemandRules = [
          workWiFi,
          disableOnCell,
          enableByDefault
      ]
    • 10:47 - Use encrypted DNS with NWConnection

      // Use encrypted DNS with NWConnection
      
      import Network
      
      let privacyContext = NWParameters.PrivacyContext(description: "EncryptedDNS")
      if let url = URL(string: "https://dnsserver.example.net/dns-query") {
          let address = NWEndpoint.hostPort(host: "2001:db8::2", port: 443)
          privacyContext.requireEncryptedNameResolution(true,
              fallbackResolver: .https(url, serverAddresses: [ address ]))
      }
      
      let tlsParams = NWParameters.tls
      tlsParams.setPrivacyContext(privacyContext)
      
      let conn = NWConnection(host: "www.example.com", port: 443, using: tlsParams)
      conn.start(queue: .main)
    • 11:35 - Validate which DNS protocol was used

      // Validate which DNS protocol was used
      
      import Network
      
      conn.requestEstablishmentReport(queue: .main) { report in
          if let report = report {
              for resolution in report.resolutions {
                  switch resolution.dnsProtocol {
                  case .https, .tls:
                      print("Used encrypted DNS!”)
                  case .udp, .tcp:
                      print("Used unencrypted DNS")
                  default:
                      // Ignore unknown protocols
             }
          }
      }
    • 12:07 - Use encrypted DNS for other APIs

      // Use encrypted DNS for other APIs
      
      import Network
      
      if let url = URL(string: "https://dnsserver.example.net/dns-query") {
          let address = NWEndpoint.hostPort(host: "2001:db8::2", port: 443)
          NWParameters.PrivacyContext.default.requireEncryptedNameResolution(true,
              fallbackResolver: .https(url, serverAddresses: [ address ]))
      }
      
      let task = URLSession.shared.dataTask(with: ...)
      task.resume()
      
      getaddrinfo(...)

Developer Footer

  • Vídeos
  • WWDC20
  • Enable encrypted DNS
  • Open Menu Close Menu
    • iOS
    • iPadOS
    • macOS
    • tvOS
    • visionOS
    • watchOS
    • App Store
    Open Menu Close Menu
    • Swift
    • SwiftUI
    • Swift Playground
    • TestFlight
    • Xcode
    • Xcode Cloud
    • Icon Composer
    • SF Symbols
    Open Menu Close Menu
    • Accessibility
    • Accessories
    • Apple Intelligence
    • Audio & Video
    • Augmented Reality
    • Business
    • Design
    • Distribution
    • Education
    • Games
    • Health & Fitness
    • In-App Purchase
    • Localization
    • Maps & Location
    • Machine Learning & AI
    • Security
    • Safari & Web
    Open Menu Close Menu
    • Documentation
    • Downloads
    • Sample Code
    • Videos
    Open Menu Close Menu
    • Help Guides & Articles
    • Contact Us
    • Forums
    • Feedback & Bug Reporting
    • System Status
    Open Menu Close Menu
    • Apple Developer
    • App Store Connect
    • Certificates, IDs, & Profiles
    • Feedback Assistant
    Open Menu Close Menu
    • Apple Developer Program
    • Apple Developer Enterprise Program
    • App Store Small Business Program
    • MFi Program
    • Mini Apps Partner Program
    • News Partner Program
    • Video Partner Program
    • Security Bounty Program
    • Security Research Device Program
    Open Menu Close Menu
    • Meet with Apple
    • Apple Developer Centers
    • App Store Awards
    • Apple Design Awards
    • Apple Developer Academies
    • WWDC
    Read the latest news.
    Get the Apple Developer app.
    Copyright © 2026 Apple Inc. All rights reserved.
    Terms of Use Privacy Policy Agreements and Guidelines