L_DicomSetClientCertificateTLS

#include "ltdic.h"

L_LTDIC_API L_UINT32 L_DicomSetClientCertificateTLS(hNet, pszPathToCertificateFile, nCertType, pszPathToKeyFile)

Sets a certificate for the client.

Parameters

HDICOMNET hNet

Handle to an existing DICOM Network. This is the handle returned from the L_DicomCreateNet function.

L_TCHAR *pszPathToCertificateFile

Character string that contains the path to the file that contains the certificate.

L_UINT32 nCertType

Flag that indicates whether the certificate is binary or text. Possible values are:

Value Meaning
L_TLS_FILETYPE_PEM Text certificate.
L_TLS_FILETYPE_ASN1 Binary certificate.

L_TCHAR *pszPathToKeyFile

Character string that contains the path to the file containing the private key. This parameter is used if the private key is available in raw mode.

Returns

Value Meaning
DICOM_SUCCESS The function was successful.
<>DICOM_SUCCESS An error occurred. Refer to the Return Codes.

Comments

Usual size for RSA key is 512 and 1024 bits. There are no known export restrictions.

The nCertType can take values L_TLS_FILETYPE_PEM (text certificate) or L_TLS_FILETYPE_ASN1 (binary certificate).

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Topics

Example

L_INT EXT_CALLBACK exPrivateKeyPasswordServer( 
   HDICOMNET hNet, 
   L_TCHAR *pszPassword, 
   L_INT nSize, 
   L_INT rwFlag, 
   L_VOID *pUserData) 
{ 
   UNREFERENCED_PARAMETER(pUserData); 
   UNREFERENCED_PARAMETER(rwFlag); 
   UNREFERENCED_PARAMETER(nSize); 
   UNREFERENCED_PARAMETER(hNet); 
 
   LPCTSTR pszMyPassword= TEXT("test"); 
 
   // copy the private key password into the pszPassword buffer, and return the length 
   lstrcpy(pszPassword, pszMyPassword); 
   return lstrlen(pszMyPassword); 
} 
 
 
L_INT DicomSetClientCertificateTLSExample(L_VOID) 
{ 
   /* start the network */ 
   L_INT nRet = L_DicomStartUp(); 
   if (nRet != DICOM_SUCCESS) 
      return nRet; 
 
   /* set the temporary file path */ 
   HDICOMNET hNet = L_DicomCreateNet(MAKE_IMAGE_PATH(TEXT("")), DICOM_SECURE_TLS); 
 
   // Set up so the private key password callback gets called 
   DICOMNETCALLBACKEXT CallbackExt; 
   memset(&CallbackExt, 0, sizeof(DICOMNETCALLBACKEXT)); 
   CallbackExt.uStructSize = sizeof(DICOMNETCALLBACKEXT); 
   CallbackExt.pfnPrivateKeyPassword = exPrivateKeyPasswordServer; 
   CallbackExt.pUserDataPrivateKeyPassword = NULL; 
 
   L_DicomSetCallbackExt(hNet, &CallbackExt); 
 
   nRet = L_DicomSetClientCertificateTLS(hNet,MAKE_IMAGE_PATH(TEXT("Client.pem")), L_TLS_FILETYPE_PEM, NULL); 
   if (nRet != DICOM_SUCCESS) 
      return nRet; 
 
   L_TCHAR strMsg[64] = {0}; 
   wsprintf(strMsg, TEXT("Loaded client certificate, result is %s"), nRet?TEXT("Error"):TEXT("Success")); 
   MessageBox(NULL, strMsg, TEXT(""), MB_OK); 
 
   /* 
   do some network communication here 
   */ 
   /* ... */ 
 
 
   /* Free the object */ 
   L_DicomFreeNet(hNet); 
 
   /* shut down the network */ 
   L_DicomShutDown(); 
 
   return DICOM_SUCCESS; 
} 
Help Version 21.0.2021.7.2
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS DICOM C API Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2021 LEAD Technologies, Inc. All Rights Reserved.