LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

CertCli.DLL and XEnroll.dll

Solved!
Go to solution
I need to import the CertCli.dll and XEnroll.dll so that I can program a Microsoft Certificate Authority.  How every both dll fail to import.  LabView reports that there are no functions defined in the header files.  I imported the dlls into LabWindows with no problem.
0 Kudos
Message 1 of 11
(4,444 Views)

I think you are going through the Tools -> Import -> Shared Library (.dll). This makes VIs out of a DLLs functions, but requires a header (*.h) file in order to complete this task. If you want to just use a DLL inside LabVIEW, the easiest way to do it is with the Call Library Function Node in the connectivity palette.

 

If you go to Connectivity ->  Libraries & Executables -> Call Library Function Node and place that on your block diagram, you can then double click this node to bring up a DLL selection window. From here you can select the DLL to use, make sure you also select WINAPI calling convention, and then select the function you would like to use in the drop down box.

 

This document is a bit out of date, but is still a good tutorial for how to accomplish this: http://zone.ni.com/devzone/cda/tut/p/id/3009 

Stephen B
0 Kudos
Message 2 of 11
(4,424 Views)

Thanks,

 

When I added CertCIi.dll to the Call Function Node on my block diagram it created two more questions.

 

1. Why does not every function in the dll get populated in the Function Name tab.  When I imported the DLL into LabWindows more functions were available.

An example is ICertConfig2GetConfig.  It is available to LabWindows and Microsoft Visual C, but it is not listed in LabView.

 

2. The attached VI fails, returning an error code of 80004003 Pointer not valid.  Does LabView handle pointers to strings?

0 Kudos
Message 3 of 11
(4,414 Views)
To import a DLL to LabWindows, you need a .h header file or a .lib file. How are you importing the DLL into LabWindows? When using dependency walker, I can see the exact same function calls inside the DLL as there are listed in the call library function node.
Stephen B
0 Kudos
Message 4 of 11
(4,386 Views)

When you installed LabWindows with the SDK you get all the Windows.h files.  They are located at

 

c:\program files\national instruments\CVI90\sdk\include. 

 

I know they have been there since LabWindows 5.0 when I started using LabWindows. 

 

You use certcli.h and the certcli.dll to create a .fp.  I have attached a screen shot of the LabWindows Library Tab showing all the normal interfaces in the CertCli library.  LabView does not import all the interfaces, like ICertGetConfig or ICertRequest2.  I have also attached a screen shot of the ICertRequest2 functions.  I use CERTCLIENTLib_ICertRequest2Submit and CERTCLIENTLib_ICertRequest2GetCertificate to program my app.

 

I have attached a screen shot of the LabView Call Library.  The ICertRequest2Submit and ICertRequest2GetCertificate are not in the Call Library.  There is a GetCACertificate but it is used for a different certificate. 

 

Also, notice the CAFindByIssuerDN or CAFindByName.  No where in the MSDN documentation do these functions exist, they are in no .h include file.  Without any documentation, we could not define the parameters to get these functions to work if we needed them.  Luckly we don't need them.

 

I do not know where LabView is picking up the CAxxxxxx functions, they are not defined in the certcli.h file.  Plus functions that we need are not being defined. 

 

When you import a dll in LabView, there is a step where you can define preprocessor statements.  Is it possible that I need to define something there so that LabView reads the .h file correctly?

 

Paul

 

 

0 Kudos
Message 5 of 11
(4,377 Views)

Hi pknight,

 

I've checked several computers here all running Windows XP and they all have the same functions in their certcli.dll. If you use a 3rd party application dependency walker (http://www.dependencywalker.com/) you can open up any dll and see the function calls inside of it. This allows us to isolate the issue from LabVIEW or LabWindows and means that the DLL you are using simply does not contain the functions you are looking for, and are defined in the .h file.

 

The difference here is you are using the .h file to define the function calls available in LabWindows, so it thinks that X function calls are available because they are in the .h file... it doesnt actually look at the dll.

 

In LabVIEW, when you try to import the DLL (tools -> import shared library (.dll)) it looks at both the DLL and the .h file, finds a mismatch and fails because the DLL on your machine, my machine, and other people around here's machines do not contain the same function calls as the ones listed in the .h file.

 

What operating system are you using?  We use Windows XP SP2 here and the version of the DLL installed is 5.1.2600.2180

 

There are different versions of certcli.dll you can find on a google search (that might have different function calls) installed on different operating systems. In fact, MSDN says that the function calls you are looking for are unsupported on Windows XP.

Stephen B
0 Kudos
Message 6 of 11
(4,345 Views)

I am running Windows XP, SP2.  The functions have to be in the dll, the include file does not define any code.  If I remove the dll, but keep the .h file in source code, I get a error because the complier can't find the functions defined in the .h.  So I have no idea what you are talking about when you say that LabWindows does not look at the dll.

 

I can create two programs one in LabWindows and one in Microsoft Visual C, include the .h file, use the certcli.dll and they work fine.  I guess LabView isn't the programming language I need.

 

 

0 Kudos
Message 7 of 11
(4,338 Views)

Paul,

 

I could not run the function call in LabVIEW either.

 

However, after turning on Maximum error handling(call library function node configuration) and putting an error handler on the output, I got LabVIEW error 1097(see attached).  This error has been documented before(search forums for 1097 - there are many matches) but it seems like most of them reference pointers. A call to a function in a DLL cannot return a pointer because there are no pointer types in LabVIEW. However, you can specify the return type as an integer that is the same size as the pointer. LabVIEW then treats the address as a simple integer, and you can pass it to future DLL calls.  This may or may not be the cause, but worth looking into.

 

 

Message Edited by Rob_K on 12-09-2008 05:14 PM
Message Edited by Rob_K on 12-09-2008 05:15 PM
Rob K
Measurements Mechanical Engineer (C-Series, USB X-Series)
National Instruments
CompactRIO Developers Guide
CompactRIO Out of the Box Video
0 Kudos
Message 8 of 11
(4,302 Views)

Rob,

 

We tried the same thing turning on Maximum error.  The reason you use pointers is because you do not know the size of the returned data.  The dll function allocates memory for the certificate and assigns it to my pointer that I passed into the function.   I then have a pointer to memory that I can use.

From LabWindows:

 

char *cCertificateBuffer = NULL;    /* create pointer */


lResult = CERTCLIENTLib_ICertRequest2GetCertificate(CertHandle, &stErrorInfo, CR_OUT_BASE64HEADER, &cCertificateBuffer);  /* pass pointer to dll */

 

iBytesWrite = WriteFile(iFileHandle, cCertificateBuffer, lFilesize);  /* use the pointer information */

 

My bigger issue is that LabView does not expose all the ICertRequest2 functions from the CertCli.dll when you try to bring the dll into LabView.   You do not get the GetCertificate or the Submit functions.  From the MSDN documentation, these function are in the CertCli.dll, I do not know why LabView does not bring these functions out.

 

Paul 

0 Kudos
Message 9 of 11
(4,281 Views)

While researching the problem I ran across this link

 

http://digital.ni.com/public.nsf/allkb/A51C520CED4FB5F98625707B006CC32F

 

It deals directly with my problem, however when I try to put an ActiveX Container on the Front Panel,  the Select ActiveX Object pull down does not show the

CertCli.  I have registered the CertCli using Regsrv32.exe

 

Paul 

0 Kudos
Message 10 of 11
(4,269 Views)