DCM-tools icon indicating copy to clipboard operation
DCM-tools copied to clipboard

dcmimport error

Open AndyYouens opened this issue 2 years ago • 12 comments

attempting to import a certificate from the IFS.

Get the following;

andy@GALATEA:~$ dcmimport /home/andy/certs/cert.pem Enter DCM keystore password: Sanity check successful checking for conflicting cert to the one with alias cert cert has no alias checking cert at alias cert The following certificates will be processed: Certificate ID 'cert': Issuer: [email protected], CN=formaserve, OU=Formaserve, O=IT, L=London, ST=London, C=UK Subject: [email protected], CN=formaserve, OU=Formaserve, O=IT, L=London, ST=London, C=UK Valid From: 2023-01-23 @ 15:09:12+0000 Valid Until: 2023-02-22 @ 15:09:12+0000 Is CA? false Do you want to import ALL of the above certificates into DCM? [y/N] y API gave error message CPFB006: An error occurred.

server job from getjobid not showing any errors. running 7.3 with latest PTFs

AndyYouens avatar Jan 25 '23 14:01 AndyYouens

That error message does not describe enough details to know why it failed. Can you try importing the certificate from DCM (IBM Digital Certificate Manager for i) and seeing what error is given from that interface?

tlhaze avatar Jan 25 '23 19:01 tlhaze

Nope, DCM doesnt like it either :-( I'll try with another cert.

AndyYouens avatar Feb 21 '23 11:02 AndyYouens

having the same issue

mauroatwork avatar May 02 '23 15:05 mauroatwork

This might be a longshot but I had a similar issue but DCM was more specific about the error...I had a CCSID issue with the certificate. Once I fixed it, I had no issues with DCM or the API call.

phelgren avatar May 03 '23 19:05 phelgren

Hello - I had a similar issue. I was able to import using DCM...just not the dcmimport command (same error as shown above).

Could this be a permission issue on the store's KDB file (or another lacking permission)? The KDB has QSYS with *RW and *PUBLIC has *R. I added the user I am signed in bash with giving *RW but that did not work either. Other ideas?

Would REALLY love to use this tool versus the web DCM since it'll make certificate work on multiple machines much easier and scriptable.

jkdavew avatar Aug 08 '23 16:08 jkdavew

@jkdavew, I'm curious if it's a CCSID-related issue as @phelgren suggested.

To rule out a permissions issue, one could copy the .KDB to a local directory and try. For instance:

cp /QIBM/UserData/ICSS/Cert/Server/DEFAULT.KDB .
chown $LOGNAME DEFAULT.KDB
dcmimport --dcm-store=./DEFAULT.KDB mycert.pem

For CCSID-related problems:

  • What type of certificate file are you using?
  • What is the file CCSID tag? (from a shell, you can run attr <myfile> ccsid)
  • How was the certificate file generated/acquired?

ThePrez avatar Aug 13 '23 22:08 ThePrez

I'm also getting this error in 1 of 3 LPARs upon running dcmimport --installed-certs. Is there a way to do a verbose to see where the error is occurring?

russelau avatar Aug 17 '23 20:08 russelau

I'm also getting this error in 1 of 3 LPARs upon running dcmimport --installed-certs. Is there a way to do a verbose to see where the error is occurring?

Yep, there's an undocumented -v option. Please try that and send in the results

ThePrez avatar Aug 17 '23 20:08 ThePrez

I'm also getting this error in 1 of 3 LPARs upon running dcmimport --installed-certs. Is there a way to do a verbose to see where the error is occurring?

Yep, there's an undocumented -v option. Please try that and send in the results

This is what I got

> y                                                                                                      
  java.io.IOException: API gave error message CPFB006: An error occurred.                                
          at com.github.ibmioss.dcmtools.utils.DcmApiCaller.runProgram(DcmApiCaller.java:266)            
          at com.github.ibmioss.dcmtools.utils.DcmApiCaller.callQykmImportKeyStore(DcmApiCaller.java:244)
          at com.github.ibmioss.dcmtools.CertFileImporter.doImport(CertFileImporter.java:139)            
          at com.github.ibmioss.dcmtools.DcmImportCmd.main(DcmImportCmd.java:137)                        
                                                                                                         
  API gave error message CPFB006: An error occurred.                                                     
  $                                                                                                      

russelau avatar Aug 17 '23 20:08 russelau

I'm not sure what error is coming back from the call to QykmImportKeyStore API, so this may not be the issue. But a change went into Java late last year to create PKCS#12 files encrypted with AES-256 and SHA-256 signatures. The change required DCM to be updated via PTFs earlier this year to support that encryption type. Please take a look at the recommended fixes page to ensure you have the needed DCM related fixes. [https://www.ibm.com/support/pages/ibm-i-74-recommended-fixes-cryptographic-servicesdcmcryptographic-co-processor] SI82940 is the one that adds support for importing certificates from a PKCS#12 file encrypted with AES-256 and SHA-256.

tlhaze avatar Aug 17 '23 21:08 tlhaze

I'm not sure what error is coming back from the call to QykmImportKeyStore API, so this may not be the issue. But a change went into Java late last year to create PKCS#12 files encrypted with AES-256 and SHA-256 signatures. The change required DCM to be updated via PTFs earlier this year to support that encryption type. Please take a look at the recommended fixes page to ensure you have the needed DCM related fixes. [https://www.ibm.com/support/pages/ibm-i-74-recommended-fixes-cryptographic-servicesdcmcryptographic-co-processor] SI82940 is the one that adds support for importing certificates from a PKCS#12 file encrypted with AES-256 and SHA-256.

Thank you for your insight. What you said makes sense. I didn't have control over PTFs and wanted to import the CA's by bulk so I settled for a workaround.

I ended up using dcmexport someFileName.pkcs12 --format=pkcs12, from the LPAR I was successful doing dcmimport --installed-certs on, and imported the pkcs12 file thru DCM on the LPAR I was getting the API gave error message CPFB006: An error occurred.

Might be helpful as a workaround to people who might be stuck on the same issue.

russelau avatar Aug 17 '23 23:08 russelau

@jkdavew, I'm curious if it's a CCSID-related issue as @phelgren suggested.

To rule out a permissions issue, one could copy the .KDB to a local directory and try. For instance:

cp /QIBM/UserData/ICSS/Cert/Server/DEFAULT.KDB .
chown $LOGNAME DEFAULT.KDB
dcmimport --dcm-store=./DEFAULT.KDB mycert.pem

For CCSID-related problems:

  • What type of certificate file are you using?
  • What is the file CCSID tag? (from a shell, you can run attr <myfile> ccsid)
  • How was the certificate file generated/acquired?

I ran the steps to copy the store, adjust permissions and import but received the same error. The ccsid is 819. The root CA file was generated in the DCM and then acquired via by exporting the issuer certificate from a connected 5250 session in ACS via the padlock icon on the bottom-right.

Doing the dcmimport with the verbose flag specified I got this java.io.IOException: API gave error message CPFB006: An error occurred. at com.github.ibmioss.dcmtools.utils.DcmApiCaller.runProgram(DcmApiCaller.java:266) at com.github.ibmioss.dcmtools.utils.DcmApiCaller.callQykmImportKeyStore(DcmApiCaller.java:244) at com.github.ibmioss.dcmtools.CertFileImporter.doImport(CertFileImporter.java:139) at com.github.ibmioss.dcmtools.DcmImportCmd.main(DcmImportCmd.java:137)

For another example, I generated a new cert with openssl but upon import had the same error. As another step I took that same new openssl certificate and was able to import via the DCM web portal.

The signature algorithm in both is sha256WithRSAEncryption. Could we still be missing PTFs if the import is working in the DCM web tool?

As an alternative approach, I was able to import on the command line by doing a call to QICSS/QYCUDRIVER (which is what the DCM web tool is using). At this point this seems to be my only approach for doing the import besides opening the web DCM tool.

jkdavew avatar Aug 30 '23 17:08 jkdavew