Ignore:
Timestamp:
Oct 26, 2009 3:47:52 PM (15 years ago)
Author:
nanang
Message:

Ticket #957:

  • Added features in secure socket: handshake timeout timer, certificate info, renegotiation API.
  • Added unit test for secure socket, along with testing purpose certificate & private key.
  • Updated build configs for secure socket.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjlib/include/pj/ssl_sock.h

    r2950 r2970  
    6161 
    6262/** 
     63 * Describe structure of certificate info. 
     64 */ 
     65typedef struct pj_ssl_cert_info { 
     66    pj_str_t    subject;            /**< Subject.               */ 
     67    pj_str_t    issuer;             /**< Issuer.                */ 
     68    unsigned    version;            /**< Certificate version.   */ 
     69    pj_time_val validity_start;     /**< Validity start.        */ 
     70    pj_time_val validity_end;       /**< Validity end.          */ 
     71    pj_bool_t   validity_use_gmt;   /**< Flag if validity date/time  
     72                                         use GMT.               */ 
     73} pj_ssl_cert_info; 
     74 
     75 
     76/** 
    6377 * Create credential from files. 
    6478 * 
     
    6781 * @param privkey_file  The file of private key. 
    6882 * @param privkey_pass  The password of private key, if any. 
     83 * @param p_cert        Pointer to credential instance to be created. 
    6984 * 
    7085 * @return              PJ_SUCCESS when successful. 
     
    323338     */ 
    324339    pj_bool_t established; 
     340 
    325341    /** 
    326342     * Describes secure socket protocol being used. 
    327343     */ 
    328344    pj_ssl_sock_proto proto; 
     345 
    329346    /** 
    330347     * Describes cipher suite being used, this will only be set when connection 
     
    332349     */ 
    333350    pj_ssl_cipher cipher; 
     351 
    334352    /** 
    335353     * Describes local address. 
    336354     */ 
    337355    pj_sockaddr local_addr; 
     356 
    338357    /** 
    339358     * Describes remote address. 
     
    341360    pj_sockaddr remote_addr; 
    342361    
     362    /** 
     363     * Describes active local certificate info. 
     364     */ 
     365    pj_ssl_cert_info local_cert_info; 
     366    
     367    /** 
     368     * Describes active remote certificate info. 
     369     */ 
     370    pj_ssl_cert_info remote_cert_info; 
     371    
    343372} pj_ssl_sock_info; 
    344373 
     
    368397     */ 
    369398    pj_ioqueue_t *ioqueue; 
     399 
     400    /** 
     401     * Specify the timer heap to use. Secure socket uses the timer to provide 
     402     * auto cancelation on asynchronous operation when it takes longer time  
     403     * than specified timeout period, e.g: security negotiation timeout. 
     404     */ 
     405    pj_timer_heap_t *timer_heap; 
    370406 
    371407    /** 
     
    431467 
    432468    /** 
    433      * Specify buffer size for delayed send operation. This setting is only 
    434      * applied for some platforms that restrict more than one outstanding  
    435      * send operation at a time, e.g: Symbian. So delaying/buffering send  
    436      * mechanism is used to allow application to send data anytime without  
    437      * worrying about current outstanding send operations. 
     469     * Specify buffer size for sending operation. Buffering sending data 
     470     * is used for allowing application to perform multiple outstanding  
     471     * send operations. Whenever application specifies this setting too 
     472     * small, sending operation may return PJ_ENOMEM. 
    438473     *   
    439      * Default value is 0, except for Symbian 8192 bytes. 
     474     * Default value is 8192 bytes. 
    440475     */ 
    441476    pj_size_t send_buffer_size; 
     
    496531     * Default value is zero/not-set. 
    497532     */ 
    498     pj_str_t servername; 
     533    pj_str_t server_name; 
    499534     
    500535} pj_ssl_sock_param; 
     
    692727 * @param flags         Flags to be given to pj_ioqueue_send(). 
    693728 * 
    694  * 
    695729 * @return              PJ_SUCCESS if data has been sent immediately, or 
    696  *                      PJ_EPENDING if data cannot be sent immediately. In 
    697  *                      this case the \a on_data_sent() callback will be 
    698  *                      called when data is actually sent. Any other return 
    699  *                      value indicates error condition. 
     730 *                      PJ_EPENDING if data cannot be sent immediately or 
     731 *                      PJ_ENOMEM when sending buffer could not handle all 
     732 *                      queued data, see \a send_buffer_size. The callback 
     733 *                      \a on_data_sent() will be called when data is actually 
     734 *                      sent. Any other return value indicates error condition. 
    700735 */ 
    701736PJ_DECL(pj_status_t) pj_ssl_sock_send(pj_ssl_sock_t *ssock, 
     
    787822 
    788823/** 
     824 * Starts SSL/TLS renegotiation over an already established SSL connection 
     825 * for this socket. This operation is performed transparently, no callback  
     826 * will be called once the renegotiation completed successfully. However,  
     827 * when the renegotiation fails, the connection will be closed and callback 
     828 * \a on_data_read() will be invoked with non-PJ_SUCCESS status code. 
     829 * 
     830 * @param ssock         The secure socket. 
     831 * 
     832 * @return              PJ_SUCCESS if renegotiation is completed immediately, 
     833 *                      or PJ_EPENDING if renegotiation has been started and 
     834 *                      waiting for completion, or the appropriate error code  
     835 *                      on failure. 
     836 */ 
     837PJ_DECL(pj_status_t) pj_ssl_sock_renegotiate(pj_ssl_sock_t *ssock); 
     838 
     839 
     840/** 
    789841 * @} 
    790842 */ 
Note: See TracChangeset for help on using the changeset viewer.