twilightdusk Absent Member.
Absent Member.
6255 views

Use RSA Private Key in script?

I have a project in Silkperformer where, as part of setting up a soap request to post, I need to pass a private key into an OpenSSL function (imported from a .dll) RSA_Sign in order to sign the request. However, I can't seem to find a way to access the private key in Silkperformer (other than having the certificate loaded which doesn't help me in this case), and further, I don't know how to make Silkperformer recognize the RSA data type that the key needs to be passed in as. Am I missing something, or does Silkperformer not support what I'm trying to do?

Tags (2)
0 Likes
13 Replies
Micro Focus Contributor
Micro Focus Contributor

RE: Use RSA Private Key in script?

Hi

Can you open a support issue for this so we can take a look at your files and provide options?

0 Likes
twilightdusk Absent Member.
Absent Member.

RE: Use RSA Private Key in script?

I can't seem to find where on the site to open a support issue, but I figured this question is general enough not to be specific to my code.

I'm using a file from OpenSSL called libeay32.dll with, among others, a function called RSA_Sign() described here. The function requires a private key to be passed in as part of the signing via an RSA data type.

I have a security certificate loaded into the project, but I need to grab the private key from it for use inside of the script, so I can call this function, and I can't seem to figure out how to do that.

0 Likes
Micro Focus Contributor
Micro Focus Contributor

RE: Use RSA Private Key in script?

When you open the cert file in a text editor and you see the private key section at the bottom, is that string value the value you need to pass to your RSA_Sign() function?

0 Likes
twilightdusk Absent Member.
Absent Member.

RE: Use RSA Private Key in script?

I've tried just passing the string into RSA_Sign where it wants the RSA data type and it resulted in an error with the virtual user halting.

0 Likes
Micro Focus Contributor
Micro Focus Contributor

RE: Use RSA Private Key in script?

Can you try passing the string into the function outside of SilkPerformer?  It is best not to involve Silk Performer at all until you have a sample working externally to prove the default behaviour of RSA_Sign is as expected.

0 Likes
twilightdusk Absent Member.
Absent Member.

RE: Use RSA Private Key in script?

I have the function working in Loadrunner which can simply #include rsa.h from OpenSSL, where this RSA type is defined.

0 Likes
Micro Focus Contributor
Micro Focus Contributor

RE: Use RSA Private Key in script?

Where is the passed private key string coming from when you use this function with Loadrunner?  

There should not be any difficulty in doing this in SP but you need to know the correct procedure to define and call external functions from dll's.  See:

External Function Declaration

Function Prototypes

Structured Data Types in External Functions

in the SP help files.

0 Likes
twilightdusk Absent Member.
Absent Member.

RE: Use RSA Private Key in script?

The private key is coming from a .pem file, read in with the function PEM_read_RSAPrivateKey(pointerToFile, null, null,  null) defined in the libeay32.dll file.

I've been reading in to the structured data type stuff, I think I'm starting to understand it, but now I'm hitting against another issue that you could perhaps clarify for me.

Based on my working Loadrunner script, which calls an RSA_Size() function to display the size of the private key, its using 256 bytes of memory. Setting a string to that size in Silk Performer doesn't solve the issue on its own, so I assume I need to use functions like SetLong() etc. to replicate the data structure from the C code. The problem is that some of the variables within the structure use something called BIGNUM, the point of which seems to be to have a variable data size. So am I going to have to figure out exactly what size every single variable inside the data structure is using in order to make use of it in Silk Performer?

0 Likes
inaniaverba Absent Member.
Absent Member.

RE: Use RSA Private Key in script?

Hi,

As part of a project that I have been worked, I needed to sign a SOAP request using a digital certificate. I not found any way to do that using only SilkPerformer language in a bdl script, in a simple SOAP/HTML project, then I built a java program with only one responsability: sign a SOAP request message using a given digital certificate. In the SilkPerformer project was very easy to use the jar file and call the method of a java class that receive the original text and responds with it signed. If there are interest in this approach, I can post more details, it´s all very simple, dry and decoupled.

0 Likes
twilightdusk Absent Member.
Absent Member.

RE: Use RSA Private Key in script?

@inaniaverba

I am very interested in this approach yes, how complicated was it to make the Java class and get it imported into Silkpeformer?

0 Likes
inaniaverba Absent Member.
Absent Member.

RE: Use RSA Private Key in script?

Hello,

I put the java project in the sourceforge:

sourceforge.net/.../signsoaprequest

In the files section, I done the upload of one jar file that you can use. There are some documentation on the wiki too.

I will make a post describing the use of this jar at the SilkPerformer, I´ll post it soon.

I hope it can help you.

0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.