Asynchronously stores (or updates) a shared password for a website.


func SecAddSharedWebCredential(_ fqdn: CFString, _ account: CFString, _ password: CFString?, _ completionHandler: @escaping (CFError?) -> Void)



The fully qualified domain name of the website requiring the password.


The account name associated with this password.


The password to be stored. Pass NULL to remove a shared password if it exists.


A block invoked when the function has completed.

The block takes one argument:


If the shared password was successfully added (or removed), NULL; if not successful, a CFError object that encapsulates the reason why the password could not be added (or removed). The error reference is automatically released after this handler is called, though you may optionally retain it for as long as needed.


This function adds a shared password item that will be accessible by Safari and apps that have the specified fully qualified domain name in their Associated Domains Entitlement. If a shared password item already exists for the specified website and account, it is updated with the provided password. To remove a password, pass NULL for the password parameter.

When this function is called, the system tries to get the site association file from the server. If the file is unavailable, the sever returns a 500-599 code.

See Also

Password Sharing

func SecRequestSharedWebCredential(CFString?, CFString?, (CFArray?, CFError?) -> Void)

Asynchronously obtains one or more shared passwords for a website.

func SecCreateSharedWebCredentialPassword() -> CFString?

Returns a randomly generated password.

let kSecSharedPassword: CFString

A dictionary key whose value is the shared password.