25 #if defined( USE_CERTSTORE ) || defined( USE_SCEP )
54 static
int queryAttributeToString(
OUT_BUFFER_FIXED( textBufMaxLen )
char *textBuffer,
59 assert(
isWritePtr( textBuffer, textBufMaxLen ) );
60 assert(
isReadPtr( attribute, attributeLen ) );
67 memcpy( textBuffer, attribute,
min( attributeLen, textBufMaxLen ) );
68 sanitiseString( textBuffer, textBufMaxLen, attributeLen );
81 IN_RANGE( 1, 64 )
const int queryReqInfoSize,
89 const int firstChar =
toLower( httpReqInfo->attribute[ 0 ] );
96 assert(
isWritePtr( attributeID,
sizeof(
int ) ) );
97 assert( ( attribute == NULL && attributeMaxLen == 0 && \
98 attributeLen == NULL ) || \
99 (
isWritePtr( attribute, attributeMaxLen ) && \
100 isWritePtr( attributeLen,
sizeof(
int ) ) ) );
102 REQUIRES( queryReqInfoSize > 0 && queryReqInfoSize <= 64 );
103 REQUIRES( ( attribute == NULL && attributeMaxLen == 0 && \
104 attributeLen == NULL ) || \
105 ( attribute != NULL && \
106 attributeMaxLen > 0 && \
108 attributeLen != NULL ) );
112 if( attribute != NULL )
114 memset( attribute, 0,
min( 16, attributeMaxLen ) );
119 for( i = 0; i < queryReqInfoSize && \
120 queryReqInfo[ i ].attrName != NULL; i++ )
122 if( httpReqInfo->
attributeLen == queryReqInfo[ i ].attrNameLen && \
123 queryReqInfo[ i ].attrName[ 0 ] == firstChar && \
125 queryReqInfo[ i ].attrName, \
126 queryReqInfo[ i ].attrNameLen ) )
128 queryInfoPtr = &queryReqInfo[ i ];
132 ENSURES( i < queryReqInfoSize );
133 if( queryInfoPtr == NULL )
138 httpReqInfo->attribute,
143 "Invalid certificate query attribute '%s'", queryText ) );
148 *attributeID = queryInfoPtr->
attrID;
149 if( attribute == NULL )
155 return( attributeCopyParams( attribute, attributeMaxLen,
156 attributeLen, httpReqInfo->value,
162 status = base64decode( attribute, attributeMaxLen, attributeLen,
163 httpReqInfo->value, httpReqInfo->
valueLen,
175 "Invalid base64-encoded query value '%s'", queryText ) );
197 sessionInfoPtr->receiveBufSize );
199 ( void ) swrite( &sessionInfoPtr->stream, &httpDataInfo,
230 sessionInfoPtr->receiveBufSize, &httpReqInfo );
231 status = sread( &sessionInfoPtr->stream, &httpDataInfo,
235 sNetGetErrorInfo( &sessionInfoPtr->stream,
236 &sessionInfoPtr->errorInfo );
241 status = processCertQuery( sessionInfoPtr, &httpReqInfo,
249 sendCertErrorResponse( sessionInfoPtr, status );
274 sendCertErrorResponse( sessionInfoPtr, status );
280 "Warning: Couldn't find certificate for '%s'",
289 sessionInfoPtr->receiveBufSize );
298 sendCertErrorResponse( sessionInfoPtr, status );
305 "Couldn't export requested certificate for '%s'",
308 sessionInfoPtr->receiveBufEnd = msgData.
length;
343 sessionInfoPtr->transactFunction = serverTransact;