<!--
{
  "availability" : [
    "iOS: 18.5.0 -",
    "iPadOS: 18.5.0 -",
    "macCatalyst: 18.5.0 -",
    "macOS: 15.5.0 -",
    "tvOS: 18.5.0 -",
    "visionOS: 2.5.0 -",
    "watchOS: 11.5.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Security",
  "identifier" : "/documentation/Security/sec_protocol_metadata_copy_server_name(_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Security"
    ],
    "preciseIdentifier" : "c:@F@sec_protocol_metadata_copy_server_name"
  },
  "title" : "sec_protocol_metadata_copy_server_name(_:)"
}
-->

# sec_protocol_metadata_copy_server_name(_:)

```
func sec_protocol_metadata_copy_server_name(_ metadata: sec_protocol_metadata_t) -> UnsafePointer<CChar>?
```

## Parameters

`metadata`

A `sec_protocol_metadata_t` instance.

## Return Value

Returns A NULL-terminated string carrying the server name, or NULL
if none was provided.

## Discussion

\abstract Obtain a copy of the server name offered by a client or server during
connection establishmet. This is the value commonly carried
in the TLS SNI extesion. The caller is expected to `free` the output
string when it is no longer needed.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)