OpenSSL

密碼學和 SSL/TLS 工具組

ossl_store

名稱

ossl_store - 儲存體擷取函式

語法

#include <openssl/store.h>

說明

一般

STORE 是一層功能,可用於從任何類型的儲存庫中擷取許多受支援的物件,其可作為檔案名稱或 URI 來尋址。

此功能支援「開啟至儲存庫的通道」、「迴圈並一次擷取一個物件」以及「關閉通道以完成」的模式。

擷取的物件會以包裝器類型 OSSL_STORE_INFO 回傳,可由此擷取 OpenSSL 類型。

URI 架構和載入器

對 URI 架構的支援稱為 STORE「載入器」,可從呼叫應用程式或載入式引擎動態新增。

對「檔案」架構的支援已內建於 libcrypto 中。請參閱 ossl_store-file(7) 以取得更多資訊。

UI_METHOD 和密碼

OSS_STORE API 沒有強制執行任何特定格式或編碼於 UI_METHOD 提供的密碼上。不過,密碼預期為 UTF-8 編碼。任何其他編碼的結果皆未定義。

範例

一般呼叫

OSSL_STORE_CTX *ctx = OSSL_STORE_open("file:/foo/bar/data.pem");

/*
 * OSSL_STORE_eof() simulates file semantics for any repository to signal
 * that no more data can be expected
 */
while (!OSSL_STORE_eof(ctx)) {
    OSSL_STORE_INFO *info = OSSL_STORE_load(ctx);

    /*
     * Do whatever is necessary with the OSSL_STORE_INFO,
     * here just one example
     */
    switch (OSSL_STORE_INFO_get_type(info)) {
    case OSSL_STORE_INFO_CERT:
        /* Print the X.509 certificate text */
        X509_print_fp(stdout, OSSL_STORE_INFO_get0_CERT(info));
        /* Print the X.509 certificate PEM output */
        PEM_write_X509(stdout, OSSL_STORE_INFO_get0_CERT(info));
        break;
    }
}

OSSL_STORE_close(ctx);

另請參閱

OSSL_STORE_INFO(3)OSSL_STORE_LOADER(3)OSSL_STORE_open(3)OSSL_STORE_expect(3)OSSL_STORE_SEARCH(3)

版權所有 2016-2018 The OpenSSL Project Authors。保留所有權利。

根據 Apache License 2.0(「授權」)授權。您不得使用此檔案,除非符合授權。您可以在原始程式碼散佈中的 LICENSE 檔案或 https://www.openssl.org/source/license.html 取得副本。