VirtualBox

Changeset 57572 in vbox for trunk/include/iprt/crypto


Ignore:
Timestamp:
Aug 28, 2015 1:31:29 AM (9 years ago)
Author:
vboxsync
Message:

IPRT: Started on accessing system certificate stores to get SSL roots for cURL.

Location:
trunk/include/iprt/crypto
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/crypto/pem.h

    r56291 r57572  
    117117 * @returns IPRT status code.
    118118 * @param   pszFilename     The path to the file to read.
    119  * @param   fFlags          Flags reserved for future hacks.
     119 * @param   fFlags          RTCRPEMREADFILE_F_XXX.
    120120 * @param   paMarkers       Array of one or more section markers to look for.
    121121 * @param   cMarkers        Number of markers in the array.
     
    125125RTDECL(int) RTCrPemReadFile(const char *pszFilename, uint32_t fFlags, PCRTCRPEMMARKER paMarkers, size_t cMarkers,
    126126                            PCRTCRPEMSECTION *ppSectionHead, PRTERRINFO pErrInfo);
     127/** @name RTCRPEMREADFILE_F_XXX - Flags for RTCrPemReadFile
     128 * @{ */
     129/** Continue on encoding error. */
     130#define RTCRPEMREADFILE_F_CONTINUE_ON_ENCODING_ERROR    RT_BIT(0)
     131/** @} */
    127132
    128133/** @} */
  • trunk/include/iprt/crypto/store.h

    r56291 r57572  
    5858
    5959
     60/**
     61 * Standard store identifiers.
     62 *
     63 * This is a least common denominator approach to system specific certificate
     64 * stores, could be extended to include things other than certificates later if
     65 * we need it.
     66 *
     67 * Windows has lots of different stores, they'll be combined by the
     68 * implementation, possibly leading to duplicates.  The user stores on Windows
     69 * seems to be unioned with the system (machine) stores.
     70 *
     71 * Linux may have different stores depending on the distro/version/installation,
     72 * in which case we'll combine them, which will most likely lead to
     73 * duplicates just like on windows.  Haven't found any easily accessible
     74 * per-user certificate stores on linux yet, so they'll all be empty.
     75 *
     76 * Mac OS X seems a lot simpler, at least from the GUI point of view.  Each
     77 * keychains as a "Certificates" folder (the "My Certificates" folder seems to
     78 * only be a matching of "Keys" and "Certificates"). However, there are two
     79 * system keychains that we need to combine, "System" and "System Roots".  As
     80 * with Windows and Linux, there is a possibility for duplicates here.
     81 *
     82 * On solaris we have currently no idea where to look for a certificate store,
     83 * so that doesn't yet work.
     84 *
     85 * Because of the OS X setup, we do not provide any purpose specific
     86 */
     87typedef enum RTCRSTOREID
     88{
     89    /** Mandatory invalid zero value. */
     90    RTCRSTOREID_INVALID = 0,
     91    /** Open the certificate store of the current user containing trusted
     92     * CAs and certificates.
     93     * @remarks This may or may not include all the certificates in the system
     94     *          store, that's host dependent.  So, you better look in both. */
     95    RTCRSTOREID_USER_TRUSTED_CAS_AND_CERTIFICATES,
     96    /** Open the certificate store of the system containg trusted CAs
     97     * and certificates. */
     98    RTCRSTOREID_SYSTEM_TRUSTED_CAS_AND_CERTIFICATES,
     99    /** End of valid values. */
     100    RTCRSTOREID_END,
     101    /** Traditional enum type compression prevention hack. */
     102    RTCRSTOREID_32BIT_HACK = 0x7fffffff
     103} RTCRSTOREID;
     104
     105/**
     106 * Creates a snapshot of a standard store.
     107 *
     108 * This will return an in-memory store containing all data from the given store.
     109 * There will be no duplicates in this one.
     110 *
     111 * @returns IPRT status code.
     112 * @retval  VWRN_ALREADY_EXISTS if the certificate is already present and
     113 *          RTCRCERTCTX_F_ADD_IF_NOT_FOUND was specified.
     114 * @param   phStore             Where to return the store handle. Use
     115 *                              RTCrStoreRelease to release it.
     116 * @param   enmStoreId          The store to snapshot.
     117 * @param   pErrInfo            Where to return additional error/warning info.
     118 *                              Optional.
     119 */
     120RTDECL(int) RTCrStoreCreateSnapshotById(PRTCRSTORE phStore, RTCRSTOREID enmStoreId, PRTERRINFO pErrInfo);
     121
    60122RTDECL(int) RTCrStoreCreateInMem(PRTCRSTORE phStore, uint32_t cSizeHint);
    61123
     
    63125RTDECL(uint32_t) RTCrStoreRelease(RTCRSTORE hStore);
    64126RTDECL(PCRTCRCERTCTX) RTCrStoreCertByIssuerAndSerialNo(RTCRSTORE hStore, PCRTCRX509NAME pIssuer, PCRTASN1INTEGER pSerialNo);
     127
     128/**
     129 * Add a certificate to the store.
     130 *
     131 * @returns IPRT status code.
     132 * @retval  VWRN_ALREADY_EXISTS if the certificate is already present and
     133 *          RTCRCERTCTX_F_ADD_IF_NOT_FOUND was specified.
     134 * @retval  VERR_WRITE_PROTECT if the store doesn't support adding.
     135 * @param   hStore              The store to add the certificate to.
     136 * @param   fFlags              RTCRCERTCTX_F_XXX. Encoding must be specified.
     137 *                              RTCRCERTCTX_F_ADD_IF_NOT_FOUND is supported.
     138 * @param   pvSrc               The encoded certificate bytes.
     139 * @param   cbSrc               The size of the encoded certificate.
     140 * @param   pErrInfo            Where to return additional error/warning info.
     141 *                              Optional.
     142 */
    65143RTDECL(int) RTCrStoreCertAddEncoded(RTCRSTORE hStore, uint32_t fFlags, void const *pvSrc, size_t cbSrc, PRTERRINFO pErrInfo);
     144
     145/**
     146 * Adds certificates from the specified file.
     147 *
     148 * @returns IPRT status code.  Even when RTCRCERTCTX_F_ADD_CONTINUE_ON_ERROR is
     149 *          used, an error is returned as an error (and not a warning).
     150 *
     151 * @param   hStore              The store to add the certificate(s) to.
     152 * @param   fFlags              RTCRCERTCTX_F_ADD_IF_NOT_FOUND and/or
     153 *                              RTCRCERTCTX_F_ADD_CONTINUE_ON_ERROR.
     154 * @param   pszFilename         The filename.
     155 * @param   pErrInfo            Where to return additional error/warning info.
     156 *                              Optional.
     157 */
    66158RTDECL(int) RTCrStoreCertAddFromFile(RTCRSTORE hStore, uint32_t fFlags, const char *pszFilename, PRTERRINFO pErrInfo);
     159
     160/**
     161 * Adds certificates from files in the specified directory.
     162 *
     163 * @returns IPRT status code.  Even when RTCRCERTCTX_F_ADD_CONTINUE_ON_ERROR is
     164 *          used, an error is returned as an error (and not a warning).
     165 *
     166 * @param   hStore              The store to add the certificate(s) to.
     167 * @param   fFlags              RTCRCERTCTX_F_ADD_IF_NOT_FOUND and/or
     168 *                              RTCRCERTCTX_F_ADD_CONTINUE_ON_ERROR.
     169 * @param   pszDir              The path to the directory.
     170 * @param   paSuffixes          List of suffixes of files to process.
     171 * @param   cSuffixes           Number of suffixes.  If this is 0, all files are
     172 *                              processed.
     173 * @param   pErrInfo            Where to return additional error/warning info.
     174 *                              Optional.
     175 */
     176RTDECL(int) RTCrStoreCertAddFromDir(RTCRSTORE hStore, uint32_t fFlags, const char *pszDir,
     177                                    PCRTSTRTUPLE paSuffixes, size_t cSuffixes, PRTERRINFO pErrInfo);
     178
     179/**
     180 * Adds all certificates from @a hStoreSrc into @a hStore.
     181 *
     182 * @returns IPRT status code.  Even when RTCRCERTCTX_F_ADD_CONTINUE_ON_ERROR is
     183 *          used, an error is returned as an error (and not a warning).
     184 *
     185 * @param   hStore              The destination store.
     186 * @param   fFlags              RTCRCERTCTX_F_ADD_IF_NOT_FOUND and/or
     187 *                              RTCRCERTCTX_F_ADD_CONTINUE_ON_ERROR.
     188 * @param   hStoreSrc           The source store.
     189 */
     190RTDECL(int) RTCrStoreCertAddFromStore(RTCRSTORE hStore, uint32_t fFlags, RTCRSTORE hStoreSrc);
     191
     192/**
     193 * Exports the certificates in the store to a PEM file
     194 *
     195 * @returns IPRT status code.
     196 * @param   hStore              The store which certificates should be exported.
     197 * @param   fFlags              Reserved for the future, MBZ.
     198 * @param   pszFilename         The name of the destination PEM file.  This will
     199 *                              be truncated.
     200 */
     201RTDECL(int) RTCrStoreCertExportAsPem(RTCRSTORE hStore, uint32_t fFlags, const char *pszFilename);
    67202
    68203RTDECL(int) RTCrStoreCertFindAll(RTCRSTORE hStore, PRTCRSTORECERTSEARCH pSearch);
     
    119254#define RTCRCERTCTX_F_ENC_PKCS6_DER    UINT32_C(0x00000002)
    120255#endif
     256/** Mask containing the flags that ends up in the certificate context. */
     257#define RTCRCERTCTX_F_MASK             UINT32_C(0x000000ff)
     258
     259/** Add APIs: Add the certificate if not found. */
     260#define RTCRCERTCTX_F_ADD_IF_NOT_FOUND          UINT32_C(0x00010000)
     261/** Add APIs: Continue on error when possible. */
     262#define RTCRCERTCTX_F_ADD_CONTINUE_ON_ERROR     UINT32_C(0x00020000)
    121263/** @} */
    122264
  • trunk/include/iprt/crypto/x509.h

    r56291 r57572  
    165165
    166166/**
    167  * Matches the directory name against a comma separated list of the comonent
     167 * Matches the directory name against a comma separated list of the component
    168168 * strings (case sensitive).
    169169 *
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette