1 /*---------------------------------------------------------------------------* 2 Project: Horizon 3 File: http_CertStore.h 4 5 Copyright (C)2010 Nintendo Co., Ltd. All rights reserved. 6 7 These coded instructions, statements, and computer programs contain 8 proprietary information of Nintendo of America Inc. and/or Nintendo 9 Company Ltd., and are protected by Federal copyright law. They may 10 not be disclosed to third parties or copied or duplicated in any form, 11 in whole or in part, without the prior written consent of Nintendo. 12 13 $Rev: 26779 $ 14 *---------------------------------------------------------------------------*/ 15 16 #ifndef NN_HTTP_HTTP_CERTSTORE_H_ 17 #define NN_HTTP_HTTP_CERTSTORE_H_ 18 19 #include <nn/util/util_NonCopyable.h> 20 #include <nn/http/http_Types.h> 21 22 #ifdef __cplusplus 23 24 namespace nn { 25 namespace http { 26 27 class Connection; 28 29 /*! 30 @brief HTTPS用の証明書ストアを表すクラスです。複数のHTTPS通信でCA証明書ストアを使いまわしたい場合に利用します。 31 */ 32 class CertStore : private nn::util::NonCopyable<CertStore> 33 { 34 friend class Connection; 35 public: 36 /*! 37 @brief コンストラクタです。 38 */ 39 explicit CertStore(); 40 41 /*! 42 @brief デストラクタです。 43 */ 44 virtual ~CertStore (void); 45 46 /*! 47 @brief 証明書ストアを初期化します。証明書を登録する前に、一度実施する必要があります。 48 @return 処理の結果が返ります。<BR> 49 */ 50 nn::Result Initialize(void); 51 52 /*! 53 @brief 証明書ストアの終了処理を行います。証明書ストアの全利用が終了したら、一度実施する必要があります。 54 @return 処理の結果が返ります。<BR> 55 */ 56 nn::Result Finalize(void); 57 58 /*! 59 @brief 証明書を登録します。複数回実行することで、複数個の証明書を登録することもできます。 60 @param[in] pCertData 証明書データ。データフォーマットは、X.509 v3の証明書データ(ASN.1定義)をDERエンコードしたバイナリデータ。 61 @param[in] certDataSize pCertDataのサイズ 。 62 @param[out] pCertIdCourier 登録した証明書のID.個別に証明書の登録解除(@ref UnRegisterCert())を実施する際に使用します。不要な場合(個別登録解除が不要の場合。CertStoreが解放されると、そこに登録されていた証明書は一括で登録解除されますので、その場合は個別登録解除は不要です。)は、未指定とすることができます。 63 @return 処理の結果が返ります。<BR> 64 */ 65 nn::Result RegisterCert(const u8* pCertData, size_t certDataSize, CertId* pCertIdCourier=NULL); 66 67 /*! 68 @brief 機器内蔵CA証明書を登録します。複数回実行することで、複数個の証明書を登録することもできます。 69 @param[in] inCaCertName 対象の機器内蔵CA証明書(sslの @ref nn::ssl::InternalCaCertの値。) 70 @param[out] pCertIdCourier 登録した証明書のID.個別に証明書の登録解除(UnRegisterCert())を実施する際に使用します。不要な場合(個別登録解除が不要の場合。CertStoreが解放されると、そこに登録されていた証明書は一括で登録解除されますので、その場合は個別登録解除は不要です。)は、未指定とすることができます。 71 @return 処理の結果が返ります。<BR> 72 */ 73 nn::Result RegisterCert(InternalCaCertId inCaCertName, CertId* pCertIdCourier=NULL); 74 75 /*! 76 @brief 証明書を登録解除します。 77 @param[in] certId 登録した証明書のID。RegisterCert()の引数で取得されたものです。 78 @return 処理の結果が返ります。<BR> 79 */ 80 nn::Result UnRegisterCert(CertId certId); 81 82 83 84 private: 85 bool m_isInitialized; 86 NN_PADDING3; 87 CertStoreId m_certStoreId; 88 89 /*! 90 @brief 証明書ストアが有効なものか否かを取得します。 91 @return 処理の結果が返ります。<BR> 92 */ IsValid()93 bool IsValid(){return m_isInitialized;} 94 }; 95 96 } // end of namespace http 97 } // end of namespace nn 98 99 #endif // __cplusplus 100 101 102 #include <nn/util/detail/util_CLibImpl.h> 103 104 105 /*! 106 @addtogroup nn_http http 107 @{ 108 109 @defgroup nn_http_CertStore_c CertStore (C) 110 111 @brief @ref nn::http::CertStore の C インタフェースモジュールです。 112 113 @{ 114 */ 115 116 /*! 117 @struct nnhttpCertStore 118 @brief HTTPのCertStoreを表す C の構造体です。 119 120 @brief 対応するクラス @ref nn::http::CertStore を参照してください。 121 */ 122 NN_UTIL_DETAIL_CLIBIMPL_DEFINE_BUFFER_CLASS(nnhttpCertStore, nn::http::CertStore, 12, u32); 123 124 /*! 125 @brief 対応する C++ 関数 @ref nn::http::CertStore::Initialize 126 */ 127 NN_EXTERN_C nnResult nnhttpCertStoreInitialize(nnhttpCertStore* this_); 128 129 /*! 130 @brief 対応する C++ 関数 @ref nn::http::CertStore::Finalize 131 */ 132 NN_EXTERN_C nnResult nnhttpCertStoreFinalize(nnhttpCertStore* this_); 133 134 /*! 135 @brief 対応する C++ 関数 @ref nn::http::CertStore::RegisterCert を参照してください。 136 */ 137 NN_EXTERN_C nnResult nnhttpCertStoreRegisterCert(nnhttpCertStore* this_, const u8* pCertData, size_t certDataSize, NnHttpCertId* pCertIdCourier); 138 139 /*! 140 @brief 対応する C++ 関数 @ref nn::http::CertStore::RegisterCert を参照してください。 141 */ 142 NN_EXTERN_C nnResult nnhttpCertStoreRegisterInternalCert(nnhttpCertStore* this_, NnHttpInternalCaCertId inCaCertName, NnHttpCertId* pCertIdCourier); 143 144 145 /*! 146 @brief 対応する C++ 関数 @ref nn::http::CertStore::UnRegisterCert を参照してください。 147 */ 148 NN_EXTERN_C nnResult nnhttpCertStoreUnRegisterCert(nnhttpCertStore* this_, NnHttpCertId certId); 149 150 151 /*! 152 @} 153 154 @} 155 */ 156 157 #endif /* NN_HTTP_HTTP_CERTSTORE_H_ */ 158