Ignore:
Timestamp:
Jan 11, 2017 1:41:31 AM (7 years ago)
Author:
ming
Message:

Fixed #1960: Export SIP transport TLS state and TLS certificate info to PJSUA2

File:
1 edited

Legend:

Unmodified
Added
Removed
  • pjproject/trunk/pjsip/include/pjsua2/endpoint.hpp

    r5417 r5518  
    125125 
    126126/** 
     127 * SSL certificate type and name structure. 
     128 */ 
     129struct SslCertName 
     130{ 
     131    pj_ssl_cert_name_type  type;            /**< Name type              */ 
     132    string                 name;            /**< The name               */ 
     133}; 
     134 
     135/** 
     136 * SSL certificate information. 
     137 */ 
     138struct SslCertInfo 
     139{ 
     140    unsigned            version;            /**< Certificate version    */ 
     141    unsigned char       serialNo[20];       /**< Serial number, array 
     142                                                 of octets, first index 
     143                                                 is MSB                 */ 
     144    string              subjectCn;          /**< Subject common name    */ 
     145    string              subjectInfo;        /**< One line subject, fields 
     146                                                 are separated by slash, e.g: 
     147                                                 "CN=sample.org/OU=HRD" */ 
     148 
     149    string              issuerCn;           /**< Issuer common name     */ 
     150    string              issuerInfo;         /**< One line subject, fields 
     151                                                 are separated by slash */ 
     152 
     153    TimeVal             validityStart;      /**< Validity start         */ 
     154    TimeVal             validityEnd;        /**< Validity end           */ 
     155    bool                validityGmt;        /**< Flag if validity  
     156                                                 date/time use GMT      */ 
     157 
     158    vector<SslCertName> subjectAltName;     /**< Subject alternative 
     159                                                 name extension         */ 
     160 
     161    string              raw;                /**< Raw certificate in PEM 
     162                                                 format, only available 
     163                                                 for remote certificate */ 
     164 
     165public: 
     166    /** 
     167     * Check if the info is set with empty values. 
     168     * 
     169     * @return          True if the info is empty. 
     170     */ 
     171    bool isEmpty() const; 
     172 
     173    /** 
     174     * Convert from pjsip 
     175     */ 
     176    void fromPj(const pj_ssl_cert_info &info); 
     177}; 
     178 
     179/** 
     180 * TLS transport information. 
     181 */ 
     182struct TlsInfo 
     183{ 
     184    /** 
     185     * Describes whether secure socket connection is established, i.e: TLS/SSL  
     186     * handshaking has been done successfully. 
     187     */ 
     188    bool                established; 
     189 
     190    /** 
     191     * Describes secure socket protocol being used, see #pj_ssl_sock_proto.  
     192     * Use bitwise OR operation to combine the protocol type. 
     193     */ 
     194    unsigned            protocol; 
     195 
     196    /** 
     197     * Describes cipher suite being used, this will only be set when connection 
     198     * is established. 
     199     */ 
     200    pj_ssl_cipher       cipher; 
     201 
     202    /** 
     203     * Describes cipher name being used, this will only be set when connection 
     204     * is established. 
     205     */ 
     206    string              cipherName; 
     207 
     208    /** 
     209     * Describes local address. 
     210     */ 
     211    SocketAddress       localAddr; 
     212 
     213    /** 
     214     * Describes remote address. 
     215     */ 
     216    SocketAddress       remoteAddr; 
     217    
     218    /** 
     219     * Describes active local certificate info. Use SslCertInfo.isEmpty() 
     220     * to check if the local cert info is available. 
     221     */ 
     222    SslCertInfo         localCertInfo; 
     223    
     224    /** 
     225     * Describes active remote certificate info. Use SslCertInfo.isEmpty() 
     226     * to check if the remote cert info is available. 
     227     */ 
     228    SslCertInfo         remoteCertInfo; 
     229 
     230    /** 
     231     * Status of peer certificate verification. 
     232     */ 
     233    unsigned            verifyStatus; 
     234 
     235    /** 
     236     * Error messages (if any) of peer certificate verification, based on 
     237     * the field verifyStatus above. 
     238     */ 
     239    StringVector        verifyMsgs; 
     240 
     241public: 
     242    /** 
     243     * Constructor. 
     244     */ 
     245    TlsInfo(); 
     246 
     247    /** 
     248     * Check if the info is set with empty values. 
     249     * 
     250     * @return          True if the info is empty. 
     251     */ 
     252    bool isEmpty() const; 
     253 
     254    /** 
     255     * Convert from pjsip 
     256     */ 
     257    void fromPj(const pjsip_tls_state_info &info); 
     258}; 
     259 
     260/** 
    127261 * Parameter of Endpoint::onTransportState() callback. 
    128262 */ 
     
    133267     */ 
    134268    TransportHandle     hnd; 
     269     
     270    /** 
     271     * The transport type. 
     272     */ 
     273    string              type; 
    135274 
    136275    /** 
     
    143282     */ 
    144283    pj_status_t         lastError; 
     284     
     285    /** 
     286     * TLS transport info, only used if transport type is TLS. Use  
     287     * TlsInfo.isEmpty() to check if this info is available. 
     288     */ 
     289    TlsInfo             tlsInfo; 
    145290}; 
    146291 
     
    10301175     */ 
    10311176    void transportClose(TransportId id) throw(Error); 
     1177     
     1178    /** 
     1179     * Start graceful shutdown procedure for this transport handle. After 
     1180     * graceful shutdown has been initiated, no new reference can be 
     1181     * obtained for the transport. However, existing objects that currently 
     1182     * uses the transport may still use this transport to send and receive 
     1183     * packets. After all objects release their reference to this transport, 
     1184     * the transport will be destroyed immediately. 
     1185     * 
     1186     * Note: application normally uses this API after obtaining the handle 
     1187     * from onTransportState() callback. 
     1188     * 
     1189     * @param tp                The transport. 
     1190     */ 
     1191    void transportShutdown(TransportHandle tp) throw(Error); 
    10321192 
    10331193    /************************************************************************* 
Note: See TracChangeset for help on using the changeset viewer.