2009-07-19 19:40 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
* contrib/hbssl/Makefile
+ contrib/hbssl/sslerr.c
+ contrib/hbssl/sslx509.c
* contrib/hbssl/ssl.c
* contrib/hbssl/sslctx.c
* contrib/hbssl/hbssl.ch
* contrib/hbssl/tests/test.prg
+ Added ERR_*() API functions.
+ Prefixed .ch contant names with HB_ to avoid collision with
ssl own headers.
+ Added SSL_CTX_SET_MODE(), SSL_CTX_GET_MODE() functions.
+ Added HB_SSL_READ_ALL(), HB_SSL_READ_LINE() functions meaning
to mimic HB_INETRECVALL() and HB_INETRECVLINE(). (probably needs
more work, it'd be great if someone who understands the guts of
these inet functions could take a look)
* SSL_PEEK() synced with SSL_READ() recent changes.
+ Added SSL_SET_MODE(), SSL_GET_MODE(), SSL_SET_MTU() functions.
+ Added SSL_GET_RBIO(), SSL_GET_WBIO() functions.
+ Added SSL_GET_PEER_CERTIFICATE() function.
+ Added X509_GET_SUBJECT_NAME(), X509_GET_ISSUER_NAME(), X509_NAME_ONELINE()
+ Added HB_SSL_MODE_* constants.
* include/hbextern.ch
* Changed to use new hbextlng.ch.
- examples/hbextern/hbextern.lst
! It wasn't deleted in 2009-07-18 21:37 UTC+0600 for some reason.
* source/rtl/console.c
! Fixed OUTSTD() and OUTERR() to output separator space
to std/err instead of alt.
* source/rtl/hbinet.c
% Minor optimization.
This commit is contained in:
@@ -17,6 +17,42 @@
|
||||
past entries belonging to author(s): Viktor Szakats.
|
||||
*/
|
||||
|
||||
2009-07-19 19:40 UTC+0200 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* contrib/hbssl/Makefile
|
||||
+ contrib/hbssl/sslerr.c
|
||||
+ contrib/hbssl/sslx509.c
|
||||
* contrib/hbssl/ssl.c
|
||||
* contrib/hbssl/sslctx.c
|
||||
* contrib/hbssl/hbssl.ch
|
||||
* contrib/hbssl/tests/test.prg
|
||||
+ Added ERR_*() API functions.
|
||||
+ Prefixed .ch contant names with HB_ to avoid collision with
|
||||
ssl own headers.
|
||||
+ Added SSL_CTX_SET_MODE(), SSL_CTX_GET_MODE() functions.
|
||||
+ Added HB_SSL_READ_ALL(), HB_SSL_READ_LINE() functions meaning
|
||||
to mimic HB_INETRECVALL() and HB_INETRECVLINE(). (probably needs
|
||||
more work, it'd be great if someone who understands the guts of
|
||||
these inet functions could take a look)
|
||||
* SSL_PEEK() synced with SSL_READ() recent changes.
|
||||
+ Added SSL_SET_MODE(), SSL_GET_MODE(), SSL_SET_MTU() functions.
|
||||
+ Added SSL_GET_RBIO(), SSL_GET_WBIO() functions.
|
||||
+ Added SSL_GET_PEER_CERTIFICATE() function.
|
||||
+ Added X509_GET_SUBJECT_NAME(), X509_GET_ISSUER_NAME(), X509_NAME_ONELINE()
|
||||
+ Added HB_SSL_MODE_* constants.
|
||||
|
||||
* include/hbextern.ch
|
||||
* Changed to use new hbextlng.ch.
|
||||
|
||||
- examples/hbextern/hbextern.lst
|
||||
! It wasn't deleted in 2009-07-18 21:37 UTC+0600 for some reason.
|
||||
|
||||
* source/rtl/console.c
|
||||
! Fixed OUTSTD() and OUTERR() to output separator space
|
||||
to std/err instead of alt.
|
||||
|
||||
* source/rtl/hbinet.c
|
||||
% Minor optimization.
|
||||
|
||||
2009-07-18 21:37 UTC+0600 April White (april users.sourceforge.net)
|
||||
- examples/hbextern/hbextern.lst
|
||||
* examples/hbextern/hbextern.prg
|
||||
|
||||
@@ -30,8 +30,10 @@ C_SOURCES=\
|
||||
sslbio.c \
|
||||
sslciph.c \
|
||||
sslctx.c \
|
||||
sslerr.c \
|
||||
sslrand.c \
|
||||
sslsess.c \
|
||||
sslx509.c \
|
||||
|
||||
PRG_HEADERS=\
|
||||
hbssl.ch \
|
||||
|
||||
@@ -76,17 +76,25 @@
|
||||
#define HB_SSLEAY_PLATFORM 3
|
||||
#define HB_SSLEAY_DIR 4
|
||||
|
||||
#define SSL_ERROR_NONE 0
|
||||
#define SSL_ERROR_SSL 1
|
||||
#define SSL_ERROR_WANT_READ 2
|
||||
#define SSL_ERROR_WANT_WRITE 3
|
||||
#define SSL_ERROR_WANT_X509_LOOKUP 4
|
||||
#define SSL_ERROR_SYSCALL 5
|
||||
#define SSL_ERROR_ZERO_RETURN 6
|
||||
#define SSL_ERROR_WANT_CONNECT 7
|
||||
#define SSL_ERROR_WANT_ACCEPT 8
|
||||
#define HB_SSL_ERROR_NONE 0
|
||||
#define HB_SSL_ERROR_SSL 1
|
||||
#define HB_SSL_ERROR_WANT_READ 2
|
||||
#define HB_SSL_ERROR_WANT_WRITE 3
|
||||
#define HB_SSL_ERROR_WANT_X509_LOOKUP 4
|
||||
#define HB_SSL_ERROR_SYSCALL 5
|
||||
#define HB_SSL_ERROR_ZERO_RETURN 6
|
||||
#define HB_SSL_ERROR_WANT_CONNECT 7
|
||||
#define HB_SSL_ERROR_WANT_ACCEPT 8
|
||||
|
||||
#define BIO_NOCLOSE 0x00
|
||||
#define BIO_CLOSE 0x01
|
||||
#define HB_SSL_MODE_ENABLE_PARTIAL_WRITE 1
|
||||
#define HB_SSL_MODE_ACCEPT_MOVING_WRITE_BUFFER 2
|
||||
#define HB_SSL_MODE_AUTO_RETRY 4
|
||||
#define HB_SSL_MODE_NO_AUTO_CHAIN 8
|
||||
|
||||
#define HB_SSL_SENT_SHUTDOWN 1
|
||||
#define HB_SSL_RECEIVED_SHUTDOWN 2
|
||||
|
||||
#define HB_BIO_NOCLOSE 0x00
|
||||
#define HB_BIO_CLOSE 0x01
|
||||
|
||||
#endif /* HBSSL_CH_ */
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
#include "hbapi.h"
|
||||
#include "hbapierr.h"
|
||||
#include "hbapiitm.h"
|
||||
#include "hbvm.h"
|
||||
|
||||
#include "hbssl.h"
|
||||
|
||||
@@ -193,6 +194,32 @@ HB_FUNC( SSL_SET_BIO )
|
||||
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
HB_FUNC( SSL_GET_RBIO )
|
||||
{
|
||||
if( hb_SSL_is( 1 ) )
|
||||
{
|
||||
SSL * ssl = hb_SSL_par( 1 );
|
||||
|
||||
if( ssl )
|
||||
hb_retptr( SSL_get_rbio( ssl ) );
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
HB_FUNC( SSL_GET_WBIO )
|
||||
{
|
||||
if( hb_SSL_is( 1 ) )
|
||||
{
|
||||
SSL * ssl = hb_SSL_par( 1 );
|
||||
|
||||
if( ssl )
|
||||
hb_retptr( SSL_get_wbio( ssl ) );
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
HB_FUNC( SSL_CONNECT )
|
||||
{
|
||||
if( hb_SSL_is( 1 ) )
|
||||
@@ -396,6 +423,194 @@ HB_FUNC( SSL_READ )
|
||||
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
/* Based on HB_INETRECVALL() */
|
||||
HB_FUNC( HB_SSL_READ_ALL )
|
||||
{
|
||||
fprintf( stdout, "ALL: SSL_READ: ENTER\n" );
|
||||
fflush( stdout );
|
||||
|
||||
if( hb_SSL_is( 1 ) )
|
||||
{
|
||||
SSL * ssl = hb_SSL_par( 1 );
|
||||
|
||||
if( ssl )
|
||||
{
|
||||
PHB_ITEM pBuffer = hb_param( 2, HB_IT_STRING );
|
||||
char * buffer;
|
||||
ULONG ulLen;
|
||||
int iLen, iMaxLen, iReceived;
|
||||
int iTimeElapsed, iTimeout = hb_parni( 4 );
|
||||
|
||||
if( hb_itemGetWriteCL( pBuffer, &buffer, &ulLen ) )
|
||||
iLen = ( int ) ulLen;
|
||||
else
|
||||
{
|
||||
iLen = 0;
|
||||
buffer = NULL;
|
||||
}
|
||||
|
||||
if( HB_ISNUM( 3 ) )
|
||||
{
|
||||
iMaxLen = hb_parni( 3 );
|
||||
if( iLen < iMaxLen )
|
||||
iMaxLen = iLen;
|
||||
}
|
||||
else
|
||||
iMaxLen = iLen;
|
||||
|
||||
hb_vmUnlock();
|
||||
|
||||
iReceived = 0;
|
||||
iTimeElapsed = 0;
|
||||
|
||||
fprintf( stdout, "ALL: SSL_READ: START\n" );
|
||||
fflush( stdout );
|
||||
|
||||
do
|
||||
{
|
||||
if( SSL_pending( ssl ) > 0 )
|
||||
{
|
||||
iLen = SSL_read( ssl, buffer + iReceived, iMaxLen - iReceived );
|
||||
|
||||
fprintf( stdout, "ALL: SSL_READ: %d\n", iLen );
|
||||
fflush( stdout );
|
||||
|
||||
if( iLen > 0 )
|
||||
iReceived += iLen;
|
||||
}
|
||||
else
|
||||
{
|
||||
iTimeElapsed += iTimeout;
|
||||
|
||||
hb_vmLock();
|
||||
|
||||
hb_retni( iReceived );
|
||||
return;
|
||||
}
|
||||
}
|
||||
while( iReceived < iMaxLen && iLen > 0 );
|
||||
|
||||
hb_vmLock();
|
||||
|
||||
if( iLen == 0 )
|
||||
hb_retni( iLen );
|
||||
else if( iLen < 0 )
|
||||
hb_retni( iLen );
|
||||
else
|
||||
hb_retni( iReceived );
|
||||
}
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
/* Based on HB_INETRECVLINE() */
|
||||
HB_FUNC( HB_SSL_READ_LINE )
|
||||
{
|
||||
fprintf( stdout, "ALL: SSL_READ_LINE: ENTER\n" );
|
||||
fflush( stdout );
|
||||
|
||||
if( hb_SSL_is( 1 ) )
|
||||
{
|
||||
SSL * ssl = hb_SSL_par( 1 );
|
||||
|
||||
if( ssl )
|
||||
{
|
||||
static const char * szPattern = "\r\n";
|
||||
|
||||
PHB_ITEM pResult = hb_param( 2, HB_IT_BYREF );
|
||||
PHB_ITEM pMaxSize = hb_param( 3, HB_IT_NUMERIC );
|
||||
PHB_ITEM pBufferSize = hb_param( 4, HB_IT_NUMERIC );
|
||||
|
||||
char cChar = '\0';
|
||||
char * Buffer;
|
||||
int iAllocated, iBufferSize, iMax;
|
||||
int iLen = 0, iPatLen;
|
||||
int iPos = 0, iTimeElapsed, iTimeout = hb_parni( 4 );
|
||||
|
||||
iBufferSize = pBufferSize ? hb_itemGetNI( pBufferSize ) : 80;
|
||||
iMax = pMaxSize ? hb_itemGetNI( pMaxSize ) : 0;
|
||||
|
||||
Buffer = ( char * ) hb_xgrab( iBufferSize );
|
||||
iAllocated = iBufferSize;
|
||||
iTimeElapsed = 0;
|
||||
iPatLen = ( int ) strlen( szPattern );
|
||||
|
||||
fprintf( stdout, "ALL: SSL_READ_LINE: START\n" );
|
||||
fflush( stdout );
|
||||
|
||||
do
|
||||
{
|
||||
if( iPos == iAllocated - 1 )
|
||||
{
|
||||
iAllocated += iBufferSize;
|
||||
Buffer = ( char * ) hb_xrealloc( Buffer, iAllocated );
|
||||
}
|
||||
|
||||
fprintf( stdout, "ALL: SSL_READ_LINE: BEFORE READ\n" );
|
||||
fflush( stdout );
|
||||
|
||||
if( SSL_pending( ssl ) > 0 )
|
||||
{
|
||||
iLen = SSL_read( ssl, &cChar, 1 );
|
||||
|
||||
fprintf( stdout, "ALL: SSL_READ_LINE: %d\n", iLen );
|
||||
fflush( stdout );
|
||||
|
||||
if( iLen > 0 )
|
||||
{
|
||||
Buffer[ iPos++ ] = cChar;
|
||||
/* verify endsequence recognition automata status */
|
||||
if( iPos >= iPatLen &&
|
||||
memcmp( Buffer + iPos - iPatLen, szPattern, iPatLen ) == 0 )
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
iTimeElapsed += iTimeout;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
while( iMax == 0 || iPos < iMax );
|
||||
|
||||
if( iLen <= 0 )
|
||||
{
|
||||
if( pResult )
|
||||
hb_itemPutNI( pResult, iLen );
|
||||
|
||||
hb_xfree( Buffer );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( iMax == 0 || iPos < iMax )
|
||||
{
|
||||
iPos -= iPatLen;
|
||||
|
||||
if( pResult )
|
||||
hb_itemPutNI( pResult, iPos );
|
||||
|
||||
hb_retclen_buffer( Buffer, iPos );
|
||||
}
|
||||
else
|
||||
{
|
||||
if( pResult )
|
||||
hb_itemPutNI( pResult, -2 );
|
||||
|
||||
hb_xfree( Buffer );
|
||||
hb_retc_null();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
HB_FUNC( SSL_PEEK )
|
||||
{
|
||||
if( hb_SSL_is( 1 ) )
|
||||
@@ -407,9 +622,9 @@ HB_FUNC( SSL_PEEK )
|
||||
PHB_ITEM pBuffer = hb_param( 2, HB_IT_STRING );
|
||||
int nRead;
|
||||
|
||||
if( pBuffer && HB_ISBYREF( 2 ) && HB_ISNUM( 3 ) )
|
||||
if( pBuffer && HB_ISBYREF( 2 ) )
|
||||
{
|
||||
nRead = hb_parni( 3 );
|
||||
nRead = HB_ISNUM( 3 ) ? hb_parni( 3 ) : ( int ) hb_parclen( 2 );
|
||||
|
||||
if( ( ULONG ) nRead <= hb_parcsiz( 2 ) )
|
||||
{
|
||||
@@ -520,7 +735,7 @@ HB_FUNC( SSL_GET_CURRENT_CIPHER )
|
||||
SSL * ssl = hb_SSL_par( 1 );
|
||||
|
||||
if( ssl )
|
||||
hb_retptr( ( void * ) SSL_get_current_cipher( ssl ) );
|
||||
hb_retptr( SSL_get_current_cipher( ssl ) );
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
@@ -1072,6 +1287,58 @@ HB_FUNC( SSL_SET_VERIFY_RESULT )
|
||||
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
HB_FUNC( SSL_SET_MODE )
|
||||
{
|
||||
if( hb_SSL_is( 1 ) )
|
||||
{
|
||||
SSL * ssl = hb_SSL_par( 1 );
|
||||
|
||||
if( ssl )
|
||||
SSL_set_mode( ssl, hb_parnl( 2 ) );
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
HB_FUNC( SSL_GET_MODE )
|
||||
{
|
||||
if( hb_SSL_is( 1 ) )
|
||||
{
|
||||
SSL * ssl = hb_SSL_par( 1 );
|
||||
|
||||
if( ssl )
|
||||
hb_parnl( SSL_get_mode( ssl ) );
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
HB_FUNC( SSL_SET_MTU )
|
||||
{
|
||||
if( hb_SSL_is( 1 ) )
|
||||
{
|
||||
SSL * ssl = hb_SSL_par( 1 );
|
||||
|
||||
if( ssl )
|
||||
SSL_set_mtu( ssl, hb_parnl( 2 ) );
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
HB_FUNC( SSL_GET_PEER_CERTIFICATE )
|
||||
{
|
||||
if( hb_SSL_is( 1 ) )
|
||||
{
|
||||
SSL * ssl = hb_SSL_par( 1 );
|
||||
|
||||
if( ssl )
|
||||
hb_retptr( SSL_get_peer_certificate( ssl ) );
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
/*
|
||||
int SSL_set_cipher_list(SSL *ssl, char *str);
|
||||
int SSL_use_PrivateKey(SSL *ssl, EVP_PKEY *pkey);
|
||||
@@ -1093,7 +1360,6 @@ char * SSL_get_ex_data( ssl, int );
|
||||
int SSL_add_dir_cert_subjects_to_stack(STACK *stack, const char *dir);
|
||||
int SSL_add_file_cert_subjects_to_stack(STACK *stack, const char *file);
|
||||
int SSL_add_client_CA(SSL *ssl, X509 *x);
|
||||
long SSL_ctrl(SSL *ssl, int cmd, long larg, char *parg);
|
||||
STACK * SSL_dup_CA_list(STACK *sk);
|
||||
SSL_CTX * SSL_get_SSL_CTX(const SSL *ssl);
|
||||
X509 * SSL_get_certificate(const SSL *ssl);
|
||||
@@ -1105,12 +1371,9 @@ void (*SSL_get_info_callback(const SSL *ssl);)()
|
||||
STACK * SSL_get_peer_cert_chain(const SSL *ssl);
|
||||
X509 * SSL_get_peer_certificate(const SSL *ssl);
|
||||
EVP_PKEY * SSL_get_privatekey(SSL *ssl);
|
||||
BIO * SSL_get_rbio(const SSL *ssl);
|
||||
SSL_SESSION *SSL_get_session(const SSL *ssl);
|
||||
int (*SSL_get_verify_callback(const SSL *ssl))(int,X509_STORE_CTX *)
|
||||
BIO * SSL_get_wbio(const SSL *ssl);
|
||||
STACK * SSL_load_client_CA_file(char *file);
|
||||
void SSL_set_bio(SSL *ssl, BIO *rbio, BIO *wbio);
|
||||
void SSL_set_client_CA_list(SSL *ssl, STACK *list);
|
||||
void SSL_set_info_callback(SSL *ssl, void (*cb);(void))
|
||||
void SSL_set_msg_callback(SSL *ctx, void (*cb)(int write_p, int version, int content_type, const void *buf, size_t len, SSL *ssl, void *arg));
|
||||
|
||||
@@ -544,6 +544,32 @@ HB_FUNC( SSL_CTX_SET_QUIET_SHUTDOWN )
|
||||
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
HB_FUNC( SSL_CTX_SET_MODE )
|
||||
{
|
||||
if( hb_SSL_CTX_is( 1 ) )
|
||||
{
|
||||
SSL_CTX * ctx = hb_SSL_CTX_par( 1 );
|
||||
|
||||
if( ctx )
|
||||
SSL_CTX_set_mode( ctx, hb_parnl( 2 ) );
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
HB_FUNC( SSL_CTX_GET_MODE )
|
||||
{
|
||||
if( hb_SSL_CTX_is( 1 ) )
|
||||
{
|
||||
SSL_CTX * ctx = hb_SSL_CTX_par( 1 );
|
||||
|
||||
if( ctx )
|
||||
hb_parnl( SSL_CTX_get_mode( ctx ) );
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
/*
|
||||
X509_STORE *SSL_CTX_get_cert_store(const SSL_CTX *);
|
||||
void SSL_CTX_set_cert_store(SSL_CTX *,X509_STORE *);
|
||||
|
||||
175
harbour/contrib/hbssl/sslerr.c
Normal file
175
harbour/contrib/hbssl/sslerr.c
Normal file
@@ -0,0 +1,175 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* OpenSSL API (ERR) - Harbour interface.
|
||||
*
|
||||
* Copyright 2009 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* www - http://www.harbour-project.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
|
||||
*
|
||||
* As a special exception, the Harbour Project gives permission for
|
||||
* additional uses of the text contained in its release of Harbour.
|
||||
*
|
||||
* The exception is that, if you link the Harbour libraries with other
|
||||
* files to produce an executable, this does not by itself cause the
|
||||
* resulting executable to be covered by the GNU General Public License.
|
||||
* Your use of that executable is in no way restricted on account of
|
||||
* linking the Harbour library code into it.
|
||||
*
|
||||
* This exception does not however invalidate any other reasons why
|
||||
* the executable file might be covered by the GNU General Public License.
|
||||
*
|
||||
* This exception applies only to the code released by the Harbour
|
||||
* Project under the name Harbour. If you copy code from other
|
||||
* Harbour Project or Free Software Foundation releases into a copy of
|
||||
* Harbour, as the General Public License permits, the exception does
|
||||
* not apply to the code that you add in this way. To avoid misleading
|
||||
* anyone as to the status of such modified files, you must delete
|
||||
* this exception notice from them.
|
||||
*
|
||||
* If you write modifications of your own for Harbour, it is your choice
|
||||
* whether to permit this exception to apply to your modifications.
|
||||
* If you do not wish that, delete this exception notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbapierr.h"
|
||||
|
||||
#include <openssl/err.h>
|
||||
|
||||
HB_FUNC( SSL_ERR_GET_ERROR )
|
||||
{
|
||||
hb_retnint( ERR_get_error() );
|
||||
}
|
||||
|
||||
HB_FUNC( SSL_ERR_PEEK_ERROR )
|
||||
{
|
||||
hb_retnint( ERR_peek_error() );
|
||||
}
|
||||
|
||||
HB_FUNC( SSL_ERR_PEEK_LAST_ERROR )
|
||||
{
|
||||
hb_retnint( ERR_peek_last_error() );
|
||||
}
|
||||
|
||||
HB_FUNC( SSL_ERR_ERROR_STRING )
|
||||
{
|
||||
char buffer[ 120 + 1 ];
|
||||
|
||||
buffer[ 0 ] = '\0';
|
||||
|
||||
ERR_error_string_n( ( unsigned long ) hb_parnint( 1 ), buffer, sizeof( buffer ) );
|
||||
|
||||
hb_retc( buffer );
|
||||
}
|
||||
|
||||
HB_FUNC( SSL_ERR_LIB_ERROR_STRING )
|
||||
{
|
||||
hb_retc( ERR_lib_error_string( ( unsigned long ) hb_parnint( 1 ) ) );
|
||||
}
|
||||
|
||||
HB_FUNC( SSL_ERR_FUNC_ERROR_STRING )
|
||||
{
|
||||
hb_retc( ERR_lib_error_string( ( unsigned long ) hb_parnint( 1 ) ) );
|
||||
}
|
||||
|
||||
HB_FUNC( SSL_ERR_REASON_ERROR_STRING )
|
||||
{
|
||||
hb_retc( ERR_lib_error_string( ( unsigned long ) hb_parnint( 1 ) ) );
|
||||
}
|
||||
|
||||
HB_FUNC( SSL_ERR_GET_ERROR_LINE )
|
||||
{
|
||||
const char * file = NULL;
|
||||
int line = 0;
|
||||
|
||||
hb_retnint( ERR_get_error_line( &file, &line ) );
|
||||
|
||||
hb_storc( file, 1 );
|
||||
hb_storni( line, 2 );
|
||||
}
|
||||
|
||||
HB_FUNC( SSL_ERR_PEEK_ERROR_LINE )
|
||||
{
|
||||
const char * file = NULL;
|
||||
int line = 0;
|
||||
|
||||
hb_retnint( ERR_peek_error_line( &file, &line ) );
|
||||
|
||||
hb_storc( file, 1 );
|
||||
hb_storni( line, 2 );
|
||||
}
|
||||
|
||||
HB_FUNC( SSL_ERR_PEEK_LAST_ERROR_LINE )
|
||||
{
|
||||
const char * file = NULL;
|
||||
int line = 0;
|
||||
|
||||
hb_retnint( ERR_peek_last_error_line( &file, &line ) );
|
||||
|
||||
hb_storc( file, 1 );
|
||||
hb_storni( line, 2 );
|
||||
}
|
||||
|
||||
HB_FUNC( SSL_ERR_GET_ERROR_LINE_DATA )
|
||||
{
|
||||
const char * file = NULL;
|
||||
int line = 0;
|
||||
const char * data = NULL;
|
||||
int flags = 0;
|
||||
|
||||
hb_retnint( ERR_get_error_line_data( &file, &line, &data, &flags ) );
|
||||
|
||||
hb_storc( file, 1 );
|
||||
hb_storni( line, 2 );
|
||||
hb_storc( data, 3 );
|
||||
hb_storni( flags, 4 );
|
||||
}
|
||||
|
||||
HB_FUNC( SSL_ERR_PEEK_ERROR_LINE_DATA )
|
||||
{
|
||||
const char * file = NULL;
|
||||
int line = 0;
|
||||
const char * data = NULL;
|
||||
int flags = 0;
|
||||
|
||||
hb_retnint( ERR_peek_error_line_data( &file, &line, &data, &flags ) );
|
||||
|
||||
hb_storc( file, 1 );
|
||||
hb_storni( line, 2 );
|
||||
hb_storc( data, 3 );
|
||||
hb_storni( flags, 4 );
|
||||
}
|
||||
|
||||
HB_FUNC( SSL_ERR_PEEK_LAST_ERROR_LINE_DATA )
|
||||
{
|
||||
const char * file = NULL;
|
||||
int line = 0;
|
||||
const char * data = NULL;
|
||||
int flags = 0;
|
||||
|
||||
hb_retnint( ERR_peek_last_error_line_data( &file, &line, &data, &flags ) );
|
||||
|
||||
hb_storc( file, 1 );
|
||||
hb_storni( line, 2 );
|
||||
hb_storc( data, 3 );
|
||||
hb_storni( flags, 4 );
|
||||
}
|
||||
90
harbour/contrib/hbssl/sslx509.c
Normal file
90
harbour/contrib/hbssl/sslx509.c
Normal file
@@ -0,0 +1,90 @@
|
||||
/*
|
||||
* $Id$
|
||||
*/
|
||||
|
||||
/*
|
||||
* Harbour Project source code:
|
||||
* OpenSSL API (X509) - Harbour interface.
|
||||
*
|
||||
* Copyright 2009 Viktor Szakats (harbour.01 syenar.hu)
|
||||
* www - http://www.harbour-project.org
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2, or (at your option)
|
||||
* any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this software; see the file COPYING. If not, write to
|
||||
* the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
|
||||
* Boston, MA 02111-1307 USA (or visit the web site http://www.gnu.org/).
|
||||
*
|
||||
* As a special exception, the Harbour Project gives permission for
|
||||
* additional uses of the text contained in its release of Harbour.
|
||||
*
|
||||
* The exception is that, if you link the Harbour libraries with other
|
||||
* files to produce an executable, this does not by itself cause the
|
||||
* resulting executable to be covered by the GNU General Public License.
|
||||
* Your use of that executable is in no way restricted on account of
|
||||
* linking the Harbour library code into it.
|
||||
*
|
||||
* This exception does not however invalidate any other reasons why
|
||||
* the executable file might be covered by the GNU General Public License.
|
||||
*
|
||||
* This exception applies only to the code released by the Harbour
|
||||
* Project under the name Harbour. If you copy code from other
|
||||
* Harbour Project or Free Software Foundation releases into a copy of
|
||||
* Harbour, as the General Public License permits, the exception does
|
||||
* not apply to the code that you add in this way. To avoid misleading
|
||||
* anyone as to the status of such modified files, you must delete
|
||||
* this exception notice from them.
|
||||
*
|
||||
* If you write modifications of your own for Harbour, it is your choice
|
||||
* whether to permit this exception to apply to your modifications.
|
||||
* If you do not wish that, delete this exception notice.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "hbapi.h"
|
||||
#include "hbapierr.h"
|
||||
|
||||
#include "hbssl.h"
|
||||
|
||||
HB_FUNC( X509_GET_SUBJECT_NAME )
|
||||
{
|
||||
X509 * x509 = ( X509 * ) hb_parptr( 1 );
|
||||
|
||||
if( x509 )
|
||||
hb_retptr( X509_get_subject_name( x509 ) );
|
||||
else
|
||||
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
HB_FUNC( X509_GET_ISSUER_NAME )
|
||||
{
|
||||
X509 * x509 = ( X509 * ) hb_parptr( 1 );
|
||||
|
||||
if( x509 )
|
||||
hb_retptr( X509_get_issuer_name( x509 ) );
|
||||
else
|
||||
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
|
||||
HB_FUNC( X509_NAME_ONELINE )
|
||||
{
|
||||
X509_NAME * x509_name = ( X509_NAME * ) hb_parptr( 1 );
|
||||
|
||||
if( x509_name )
|
||||
{
|
||||
char buffer[ 1024 ];
|
||||
X509_NAME_oneline( x509_name, buffer, sizeof( buffer ) );
|
||||
hb_retc( buffer );
|
||||
}
|
||||
else
|
||||
hb_errRT_BASE( EG_ARG, 2010, NULL, HB_ERR_FUNCNAME, HB_ERR_ARGS_BASEPARAMS );
|
||||
}
|
||||
@@ -44,7 +44,7 @@ PROCEDURE Main()
|
||||
? "-------"
|
||||
|
||||
socket := hb_inetCreate()
|
||||
? hb_inetTimeout( socket, 500 )
|
||||
? hb_inetTimeout( socket, 2500 )
|
||||
? hb_inetConnect( "www.fortify.net", 443, socket )
|
||||
? hb_inetErrorCode( socket )
|
||||
|
||||
@@ -83,7 +83,7 @@ PROCEDURE Main()
|
||||
? "SSL_CIPHER_GET_NAME" , SSL_CIPHER_GET_NAME( cipher )
|
||||
? "SSL_CIPHER_GET_VERSION", SSL_CIPHER_GET_VERSION( cipher )
|
||||
? "SSL_CIPHER_GET_BITS" , SSL_CIPHER_GET_BITS( cipher, @bits ), bits
|
||||
// ? "SSL_CIPHER_DESCRIPTION", SSL_CIPHER_DESCRIPTION( cipher )
|
||||
? "SSL_CIPHER_DESCRIPTION", SSL_CIPHER_DESCRIPTION( cipher )
|
||||
|
||||
? "SSL_WRITE", tmp := SSL_WRITE( ssl, "GET / http/1.1" + hb_inetCRLF() + "Host: " + "www.fortify.net" + hb_inetCRLF() + hb_inetCRLF() )
|
||||
? "SSL_GET_ERROR", SSL_GET_ERROR( ssl, tmp )
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
#
|
||||
# $Id$
|
||||
#/
|
||||
|
||||
#Layout: one contrib entry per line, that being a comma separated list of: folder, .CH file name, description
|
||||
#folder, hbx$$$$$.ch, description without commas
|
||||
|
||||
gtalleg, hbxalleg, Allegro based virtual GT with graphic extensions
|
||||
gtqtc, hbxgtqtc, Video subsystem for Windows using GUI windows instead of Console - QTC
|
||||
gtwvg, hbxgtwvg, Video subsystem for Windows using GUI windows instead of Console - WVG
|
||||
hbblat, hbxblat, BLAT library API
|
||||
hbbmcdx, hbxbmcdx, BMDBFCDX RDD, xHarbour Project source code
|
||||
hbbtree, hbxbtree, BTree library API
|
||||
hbclipsm, hbxclpsm
|
||||
hbcrypt, hbxcrypt
|
||||
hbct, hbxct, Clipper Tools library API
|
||||
hbcurl, hbxcurl, curl library API
|
||||
hbfbird, hbxfbird, Firebird RDBMS library API
|
||||
hbfimage, hbxfimge, FreeImage graphic library API
|
||||
#hbgd, hbxgd, GD graphic library class, # unnecessary as this folder has its own .ch file
|
||||
hbgt, hbxgt, GT Clipper library API
|
||||
hbhpdf, hbxhpdf, hbhpdf/libharu library API
|
||||
hbmisc, hbxmisc
|
||||
hbmsql, hbxmsql
|
||||
|
||||
# the format of hbmysql/mysqlold.c is such that hbextern.exe will not parse out the function names
|
||||
hbmysql, hbxmysql, MySQL DBMS library API
|
||||
|
||||
hbmzip, hbxmzip, minizip library API
|
||||
hbnf, hbxnf, Nanforums library API
|
||||
hbodbc, hbxodbc, ODBC library API
|
||||
hbpgsql, hbxpgsql, PostgreSQL RDD library API
|
||||
hbqt, hbxqt, QT library API
|
||||
hbsqlit3, hbxsqlt3, SQLite3 library API
|
||||
hbssl, hbxssl, OpenSSL library API
|
||||
hbtip, hbxtip, TIP Internet protocol library API
|
||||
hbtpathy, hbxtpthy, Telepathy library API
|
||||
hbvpdf, hbxvpdf, PDF library API
|
||||
hbwin, hbxwin, Windows library API
|
||||
hbxbp, hbxxbp, xBase++ library API
|
||||
hbziparc, hbxzip, ZipArchive library API
|
||||
rddado, hbxado, ADO RDD library API
|
||||
rddads, hbxads, Advantage Database Server RDD library API
|
||||
rddsql, hbxsql, SQL RDD library API
|
||||
xhb, hbxxhb, xHarbour library API
|
||||
xpp, hbxxpp, xBase++ library API
|
||||
@@ -54,6 +54,7 @@
|
||||
#define HB_EXTERN_CH_
|
||||
|
||||
#include "hbextcdp.ch"
|
||||
#include "hbextlng.ch"
|
||||
|
||||
/* CA-Cl*pper compatible standard functions */
|
||||
|
||||
@@ -1036,75 +1037,6 @@ EXTERNAL HB_MUTEXSUBSCRIBE
|
||||
EXTERNAL HB_MUTEXSUBSCRIBENOW
|
||||
EXTERNAL HB_MUTEXQUEUEINFO
|
||||
|
||||
/* lang support */
|
||||
EXTERNAL HB_LANG_BE866
|
||||
EXTERNAL HB_LANG_BEWIN
|
||||
EXTERNAL HB_LANG_BG866
|
||||
EXTERNAL HB_LANG_BGISO
|
||||
EXTERNAL HB_LANG_BGMIK
|
||||
EXTERNAL HB_LANG_BGWIN
|
||||
EXTERNAL HB_LANG_CA
|
||||
EXTERNAL HB_LANG_CS852
|
||||
EXTERNAL HB_LANG_CSISO
|
||||
EXTERNAL HB_LANG_CSKAM
|
||||
EXTERNAL HB_LANG_CSWIN
|
||||
EXTERNAL HB_LANG_DE
|
||||
EXTERNAL HB_LANG_DEWIN
|
||||
EXTERNAL HB_LANG_EL
|
||||
EXTERNAL HB_LANG_ELWIN
|
||||
EXTERNAL HB_LANG_EN
|
||||
EXTERNAL HB_LANG_EO
|
||||
EXTERNAL HB_LANG_ES
|
||||
EXTERNAL HB_LANG_ESWIN
|
||||
EXTERNAL HB_LANG_EU
|
||||
EXTERNAL HB_LANG_FR
|
||||
EXTERNAL HB_LANG_GL
|
||||
EXTERNAL HB_LANG_HE862
|
||||
EXTERNAL HB_LANG_HEWIN
|
||||
EXTERNAL HB_LANG_HR437
|
||||
EXTERNAL HB_LANG_HR852
|
||||
EXTERNAL HB_LANG_HRISO
|
||||
EXTERNAL HB_LANG_HRWIN
|
||||
EXTERNAL HB_LANG_HU852
|
||||
EXTERNAL HB_LANG_HUCWI
|
||||
EXTERNAL HB_LANG_HUISO
|
||||
EXTERNAL HB_LANG_HUWIN
|
||||
EXTERNAL HB_LANG_ID
|
||||
EXTERNAL HB_LANG_IS850
|
||||
EXTERNAL HB_LANG_IT
|
||||
EXTERNAL HB_LANG_KO
|
||||
EXTERNAL HB_LANG_LTWIN
|
||||
EXTERNAL HB_LANG_NL
|
||||
EXTERNAL HB_LANG_PL852
|
||||
EXTERNAL HB_LANG_PLISO
|
||||
EXTERNAL HB_LANG_PLMAZ
|
||||
EXTERNAL HB_LANG_PLWIN
|
||||
EXTERNAL HB_LANG_PT
|
||||
EXTERNAL HB_LANG_PTISO
|
||||
EXTERNAL HB_LANG_RO
|
||||
EXTERNAL HB_LANG_RU866
|
||||
EXTERNAL HB_LANG_RUKOI8
|
||||
EXTERNAL HB_LANG_RUWIN
|
||||
EXTERNAL HB_LANG_SK852
|
||||
EXTERNAL HB_LANG_SKISO
|
||||
EXTERNAL HB_LANG_SKKAM
|
||||
EXTERNAL HB_LANG_SKWIN
|
||||
EXTERNAL HB_LANG_SL437
|
||||
EXTERNAL HB_LANG_SL852
|
||||
EXTERNAL HB_LANG_SLISO
|
||||
EXTERNAL HB_LANG_SLWIN
|
||||
EXTERNAL HB_LANG_SR852
|
||||
EXTERNAL HB_LANG_SRISO
|
||||
EXTERNAL HB_LANG_SRWIN
|
||||
EXTERNAL HB_LANG_TR857
|
||||
EXTERNAL HB_LANG_TRWIN
|
||||
EXTERNAL HB_LANG_UA866
|
||||
EXTERNAL HB_LANG_UADOS
|
||||
EXTERNAL HB_LANG_UAKOI8
|
||||
EXTERNAL HB_LANG_UAWIN
|
||||
EXTERNAL HB_LANG_ZHB5
|
||||
EXTERNAL HB_LANG_ZHGB
|
||||
|
||||
EXTERNAL HB_AT
|
||||
EXTERNAL HB_ATI
|
||||
EXTERNAL HB_RAT
|
||||
|
||||
@@ -294,7 +294,7 @@ HB_FUNC( OUTSTD ) /* writes a list of values to the standard output device */
|
||||
for( iParam = 1; iParam <= iPCount; iParam++ )
|
||||
{
|
||||
if( iParam > 1 )
|
||||
hb_conOutAlt( " ", 1 );
|
||||
hb_conOutStd( " ", 1 );
|
||||
pszString = hb_itemString( hb_param( iParam, HB_IT_ANY ), &ulLen, &fFree );
|
||||
if( ulLen )
|
||||
hb_conOutStd( pszString, ulLen );
|
||||
@@ -313,7 +313,7 @@ HB_FUNC( OUTERR ) /* writes a list of values to the standard error device */
|
||||
for( iParam = 1; iParam <= iPCount; iParam++ )
|
||||
{
|
||||
if( iParam > 1 )
|
||||
hb_conOutAlt( " ", 1 );
|
||||
hb_conOutErr( " ", 1 );
|
||||
pszString = hb_itemString( hb_param( iParam, HB_IT_ANY ), &ulLen, &fFree );
|
||||
if( ulLen )
|
||||
hb_conOutErr( pszString, ulLen );
|
||||
|
||||
@@ -275,6 +275,8 @@ static void hb_inetLinuxSigusrHandle( int sig )
|
||||
# endif
|
||||
#endif
|
||||
|
||||
static const char * s_inetCRLF = "\r\n";
|
||||
|
||||
/* JC1: we need it volatile to be minimally thread safe. */
|
||||
static volatile int s_iSessions = 0;
|
||||
|
||||
@@ -1189,7 +1191,7 @@ static void s_inetRecvPattern( const char * szPattern )
|
||||
|
||||
HB_FUNC( HB_INETRECVLINE )
|
||||
{
|
||||
s_inetRecvPattern( "\r\n" );
|
||||
s_inetRecvPattern( s_inetCRLF );
|
||||
}
|
||||
|
||||
HB_FUNC( HB_INETRECVENDBLOCK )
|
||||
@@ -1483,7 +1485,7 @@ static void s_inetSendInternal( int iMode )
|
||||
}
|
||||
else if( iLen == 0 )
|
||||
{
|
||||
HB_SOCKET_SET_ERROR2( Socket, -1 , "Timeout" );
|
||||
HB_SOCKET_SET_ERROR2( Socket, -1, "Timeout" );
|
||||
break;
|
||||
}
|
||||
else
|
||||
@@ -2176,7 +2178,7 @@ HB_FUNC( HB_INETDGRAMRECV )
|
||||
|
||||
HB_FUNC( HB_INETCRLF )
|
||||
{
|
||||
hb_retc_const( "\r\n" );
|
||||
hb_retc_const( s_inetCRLF );
|
||||
}
|
||||
|
||||
HB_FUNC( HB_INETISSOCKET )
|
||||
|
||||
Reference in New Issue
Block a user