<!--
{
  "availability" : [
    "macOS: 10.2.0 - 10.15.0"
  ],
  "documentType" : "symbol",
  "framework" : "Security",
  "identifier" : "/documentation/Security/SSLSetDiffieHellmanParams(_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Security"
    ],
    "preciseIdentifier" : "c:@F@SSLSetDiffieHellmanParams"
  },
  "title" : "SSLSetDiffieHellmanParams(_:_:_:)"
}
-->

# SSLSetDiffieHellmanParams(_:_:_:)

Specifies Diffie-Hellman parameters for a given context.

```
func SSLSetDiffieHellmanParams(_ context: SSLContext, _ dhParams: UnsafeRawPointer?, _ dhParamsLen: Int) -> OSStatus
```

## Parameters

`context`

An SSL session context reference.

`dhParams`

A pointer to a buffer containing the Diffie-Hellman parameters in Open SSL DER format.

`dhParamsLen`

A value representing the size of the buffer pointed to by the `dhParams` parameter.

## Return Value

A result code. See [Secure Transport Result Codes](/documentation/Security/secure-transport-result-codes).

## Discussion

You can use this function to specify a set of Diffie-Hellman parameters to be used by Secure Transport for a specific session. Use of this function is optional. If Diffie-Hellman ciphers are allowed, the server and client negotiate a Diffie-Hellman cipher, and this function has not been called, then secure transport calculates a set of process wide parameters. However, that process can take as long as 30 seconds. Diffie-Hellman ciphers are enabled by default. See [`SSLSetEnabledCiphers(_:_:_:)`](/documentation/Security/SSLSetEnabledCiphers(_:_:_:)).

In SSL/TLS, Diffie-Hellman parameters are always specified by the server. Therefore, this function can be called only by the server side of the connection.

You can use the [`SSLGetDiffieHellmanParams(_:_:_:)`](/documentation/Security/SSLGetDiffieHellmanParams(_:_:_:)) function to retrieve Diffie-Hellman parameters specified in an earlier call to [`SSLSetDiffieHellmanParams(_:_:_:)`](/documentation/Security/SSLSetDiffieHellmanParams(_:_:_:)).

---

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)