Mac Guides | Samples

MonoMac.Security.SecKeyChain Class

Access to the operating system keychain.

See Also: SecKeyChain

Syntax

public static class SecKeyChain

Remarks

This class provides both basic and advanced means to manipulate iOS or MacOS keychain. Majority Mac OS X keychain scenarios involve adding or looking up the stored password. AddInternetPassword and FindInternetPassword provide high-level API to accomplish this for Internet passwords. For generic passwords, the AddGenericPassword and FindInternetPassword perform the same task. Other methods of this class may be used for iOS or more advanced MacOS keychain scenarios.

C# Example

var password = Encoding.UTF8.GetBytes("pA$$w0rd");
SecKeyChain.AddInternetPassword("bugzilla.novell.com", "miguel", password);

C# Example

byte[] password = null;
var code = SecKeyChain.FindInternetPassword("bugzilla.novell.com", "miguel", out password);
if (code == SecStatusCode.Success) {
	var passwordString = Encoding.UTF8.GetString(password);
	Console.WriteLine("The password for the account is: {0}", passwordString);
}

C# Example

var query = new SecRecord (SecKind.InternetPassword) {
   Sever = "bugzilla.novell.com",
   Account = "miguel"
};
var password = SecKeyChain.QueryAsData (query);
Console.WriteLine ("The password for the account is: {0}", password);

Requirements

Namespace: MonoMac.Security
Assembly: XamMac (in XamMac.dll)
Assembly Versions: 0.0.0.0

The members of MonoMac.Security.SecKeyChain are listed below.

See Also: Object

Public Methods

static
Add(SecRecord) : SecStatusCode
Adds the specified record to the keychain.
static
AddGenericPassword(String, String, Byte[]) : SecStatusCode
The method allows to add a new generic password to the default keychain (MacOS only).
static
AddInternetPassword(String, String, Byte[], SecProtocol, Int16, String, SecAuthenticationType, String) : SecStatusCode
This method allows to add a new Internet password to the default keychain (MacOS only).
static
FindGenericPassword(String, String, out Byte[]) : SecStatusCode
This method looks up for a generic password in the default keychain (MacOS only).
static
FindInternetPassword(String, String, out Byte[], SecProtocol, Int16, String, SecAuthenticationType, String) : SecStatusCode
This method looks up for the password in the default MacOS keychain for Internet accounts.
static
QueryAsData(SecRecord) : NSData
Fetches an NSData record from the Keychain.
static
QueryAsData(SecRecord, Int32) : NSData[]
static
QueryAsData(SecRecord, Boolean, out SecStatusCode) : NSData
static
QueryAsData(SecRecord, Boolean, Int32, out SecStatusCode) : NSData[]
static
QueryAsRecord(SecRecord, out SecStatusCode) : SecRecord
static
QueryAsRecord(SecRecord, Int32, out SecStatusCode) : SecRecord[]
static
Remove(SecRecord) : SecStatusCode
static
Update(SecRecord, SecRecord) : SecStatusCode