پرش به مستندات
C#

client.Encryption

هر متد در این فضای نام: امضا، پارامترها، آنچه برمی‌گرداند و یک نمونه.

متدها

The OpenPGP public keys that let senders seal mail to your addresses: list the ones you published, publish or rotate one, and look up the keys of recipients before sealing a message.

Encryption.ListKeysAsync

List your published encryption keys

محدوده‌های دسترسیemails:read
امضای متد
Task<IReadOnlyList<JsonObject>> ListKeysAsync(    string? apiKey = null,    CancellationToken cancellationToken = default)

Returns every OpenPGP public key published for an address in this workspace, newest first, the Encryption page of the app. Retired keys are included, with revokedAt and revokedReason set, and the live key of each address has revokedAt null.

Published keys belong to a person. A key reads and publishes the keys of the workspace owner, and an access token those of the person who connected the app. A key limited to particular addresses lists only the keys of those addresses.

پارامترها

apiKeystring?

Overrides the client's API key for this call only.

cancellationTokenCancellationToken

Cancels the request.

خروجی

A list of JsonObject items, each with id, address, fingerprint, publicKey, algorithm, createdAt, revokedAt and revokedReason.

نمونه

var keys = await client.Encryption.ListKeysAsync(); foreach (var key in keys){    var state = key["revokedAt"] is null ? "live" : "retired";     Console.WriteLine($"{key["address"]} {key["fingerprint"]} {state}");}

نکته‌ها

  • Only public keys travel through the API. The private key stays on the device that made it.

همچنین در دسترس در

API
GET /encryption/keys
TypeScript
encryption.listKeys()
Python
encryption.list_keys()
Ruby
encryption.list_keys
PHP
encryption->listKeys
Go
Encryption.ListKeys
Java
encryption().listKeys
CLI
openemail encryption list-keys

Encryption.PublishKeyAsync

Publish a public key for one of your addresses

محدوده‌های دسترسیemails:read
امضای متد
Task<JsonObject> PublishKeyAsync(    IReadOnlyDictionary<string, object?> body,    string? apiKey = null,    CancellationToken cancellationToken = default)

Publishes an armored OpenPGP public key for one of your addresses, so that senders can seal mail to it, as Publish on the Encryption page does. The address has to be an address of this workspace on a verified domain, switched on, and one you may use.

An address keeps one live key. To rotate, pass the fingerprint of the live key as replaces: it is retired as the new key is published. Mail already sealed to the old key stays readable only with the old private key.

Published keys belong to a person. A key reads and publishes the keys of the workspace owner, and an access token those of the person who connected the app.

پارامترها

addressstringالزامی

The address the key is for.

publicKeystringالزامی

The armored OpenPGP PUBLIC KEY BLOCK, up to 64 KB.

fingerprintstringالزامی

The fingerprint of the key, 40 upper-case hexadecimal characters.

algorithmstring

The algorithm of the key, such as ed25519, for display only.

replacesstring

The fingerprint of the live key this one replaces, to rotate it.

apiKeystring?

Overrides the client's API key for this call only.

cancellationTokenCancellationToken

Cancels the request.

خروجی

A JsonObject for the key, now live, with the same fields as each entry of Encryption.ListKeysAsync.

نمونه

var armored = """    -----BEGIN PGP PUBLIC KEY BLOCK-----     mDMEZk3x8RYJKwYBBAHaRw8BAQdA1n3cG0s7t2x0uVYw8Wq3m2Jb6p9vV5k4sQ1n    =q8Xz    -----END PGP PUBLIC KEY BLOCK-----    """; var key = await client.Encryption.PublishKeyAsync(new Body{    ["address"] = "[email protected]",    ["publicKey"] = armored,    ["fingerprint"] = "3F2A9C1B7E4D5F60A1B2C3D4E5F60718293A4B5C",    ["algorithm"] = "ed25519",}); Console.WriteLine($"{key["id"]} {key["fingerprint"]}");

نکته‌ها

  • With an OAuth access token it asks for a verification code: until the app has verified one, it is refused with 403 step_up_required. An API key is never asked.

  • A second key while one is live, without replaces, is 409 key_already_published, and so is a key that was published for the address before. An address on a domain that is not verified yet is 409 domain_not_verified, and an address you may not use is 403 address_not_allowed.

  • The SDK does not retry it.

همچنین در دسترس در

API
POST /encryption/keys
TypeScript
encryption.publishKey()
Python
encryption.publish_key()
Ruby
encryption.publish_key
PHP
encryption->publishKey
Go
Encryption.PublishKey
Java
encryption().publishKey
CLI
openemail encryption publish-key

Encryption.LookupKeysAsync

Find the keys to seal mail to

محدوده‌های دسترسیemails:send
امضای متد
Task<IReadOnlyList<JsonObject>> LookupKeysAsync(    IEnumerable<string> addresses,    string? apiKey = null,    CancellationToken cancellationToken = default)

Returns the live public keys published for each recipient address, the lookup the composer makes before it seals a message. An address with no key comes back with keys empty, so mail to it cannot be sealed. Only keys published by somebody who can read the address count.

پارامترها

addressesIEnumerable<string>الزامی

Recipient addresses, at most 51, as a dictionary or one comma-separated string. They are sent comma-separated.

apiKeystring?

Overrides the client's API key for this call only.

cancellationTokenCancellationToken

Cancels the request.

خروجی

A list of JsonObject items, one per address, each with address and keys, every key an object with fingerprint, publicKey and createdAt.

نمونه

var found = await client.Encryption.LookupKeysAsync(new[] { "[email protected]", "[email protected]" }); foreach (var entry in found){    Console.WriteLine($"{entry["address"]}: {((entry["keys"]?.AsArray().Count ?? 0) == 0 ? "cannot be sealed" : "can be sealed")}");}

نکته‌ها

  • A display name in angle brackets is read as its address.

همچنین در دسترس در

API
GET /encryption/keys/lookup
TypeScript
encryption.lookupKeys()
Python
encryption.lookup_keys()
Ruby
encryption.lookup_keys
PHP
encryption->lookupKeys
Go
Encryption.LookupKeys
Java
encryption().lookupKeys
CLI
openemail encryption lookup-keys