provider.c
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include <osp/osp.h>
00032 #include <osp/osputils.h>
00033 #include "../../dprint.h"
00034 #include "provider.h"
00035
00036 extern unsigned int _osp_sp_number;
00037 extern char* _osp_sp_uris[];
00038 extern unsigned long _osp_sp_weights[];
00039 extern unsigned char* _osp_private_key;
00040 extern unsigned char* _osp_local_certificate;
00041 extern unsigned char* _osp_ca_certificate;
00042 extern int _osp_ssl_lifetime;
00043 extern int _osp_persistence;
00044 extern int _osp_retry_delay;
00045 extern int _osp_retry_limit;
00046 extern int _osp_timeout;
00047 extern int _osp_crypto_hw;
00048 extern OSPTPROVHANDLE _osp_provider;
00049
00050
00051
00052
00053
00054 int ospSetupProvider(void)
00055 {
00056 OSPTPRIVATEKEY privatekey;
00057 OSPTCERT localcert;
00058 OSPTCERT cacert;
00059 OSPTCERT* cacerts[1];
00060 int result;
00061
00062 cacerts[0] = &cacert;
00063
00064 if ((result = OSPPInit(_osp_crypto_hw)) != 0) {
00065 LM_ERR("failed to initalize OSP (%d)\n", result);
00066 } else if (OSPPUtilLoadPEMPrivateKey(_osp_private_key, &privatekey) != 0) {
00067 LM_ERR("failed to load private key from '%s'\n", _osp_private_key);
00068 } else if (OSPPUtilLoadPEMCert(_osp_local_certificate, &localcert) != 0) {
00069 LM_ERR("failed to load local certificate from '%s'\n",_osp_local_certificate);
00070 } else if (OSPPUtilLoadPEMCert(_osp_ca_certificate, &cacert) != 0) {
00071 LM_ERR("failed to load CA certificate from '%s'\n", _osp_ca_certificate);
00072 } else {
00073 result = OSPPProviderNew(
00074 _osp_sp_number,
00075 (const char**)_osp_sp_uris,
00076 _osp_sp_weights,
00077 "http://localhost:1234",
00078 &privatekey,
00079 &localcert,
00080 1,
00081 (const OSPTCERT**)cacerts,
00082 1,
00083 _osp_ssl_lifetime,
00084 _osp_sp_number,
00085 _osp_persistence,
00086 _osp_retry_delay,
00087 _osp_retry_limit,
00088 _osp_timeout,
00089 "",
00090 "",
00091 &_osp_provider);
00092 if (result != 0) {
00093 LM_ERR("failed to create provider (%d)\n", result);
00094 } else {
00095 LM_DBG("created new (per process) provider '%d'\n", _osp_provider);
00096 result = 0;
00097 }
00098 }
00099
00100
00101
00102
00103
00104 if (privatekey.PrivateKeyData != NULL) {
00105
00106 }
00107
00108 if (localcert.CertData != NULL) {
00109
00110 }
00111
00112 if (cacert.CertData != NULL) {
00113
00114 }
00115
00116 return result;
00117 }
00118
00119
00120
00121
00122
00123 int ospDeleteProvider(void)
00124 {
00125 int result;
00126
00127 if ((result = OSPPProviderDelete(_osp_provider, 0)) != 0) {
00128 LM_ERR("failed to erase provider '%d' (%d)\n", _osp_provider, result);
00129 }
00130
00131 return result;
00132 }
00133