IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.



#Automation


#Applicationintegration
#webMethods
#Integration
 View Only

PGP using the --batch command

  • 1.  PGP using the --batch command

    Posted 05/11/22 12:52 AM

    I use IS 10.1 on the Linux environment and am trying to do a PGP encryption. The customer has provided a sample command that will allow me to do the encryption which is

    gpg --batch --armour --encrypt --recipient [xxxx] --sign  --local-user [clientPrivateKey] --passphrase [clientPassphrase] --output "[outFilename.txt.asc]" "[inFilename.txt]"
    

    The above command works perfectly when run manually at the command prompt of our server with the correct parameters set, however I would like to have this running automatically via a service.

    Initially I have tried to use the package found in this forum WxPGPUtils to perform the encryption, however I was told that it did not have the parameter --armour set.

    I thought of passing the above command into a java service (an inbuilt existing service) which will execute the command under Linux. This java service is to kick off a process to execute the command line passed in as parameters and waits for it to end and returns the output back to the pipeline. This java service appears to work well for our other usages.

    Using the java service with the above command, when the --batch is set the java service doesn’t appear to come back at all. It appears to be waiting. Below is our java code. Is a batch mode allowed within a java exec command? If not is there another way to get around this issue?

    Attempt 2
    Still using the java service, I have tried to remove the --batch command and instead replaced it with --no-tty

    gpg --no-tty --armour --encrypt --recipient [xxxx] --sign --local-user [clientPrivateKey] --passphrase [clientPassphrase] --output “[outFilename.txt.asc]” “[inFilename.txt]”

    The java service came back with the following error
    gpg: cancelled by user
    gpg: skipped “[clientPrivateKey]”: Operation cancelled
    gpg: [stdin]: sign+encrypt failed: Operation cancelled

    Is there a way to get around this issue?

    Attempt 3
    When I tried to remove the --no-tty, so the command is
    gpg --armour --encrypt --recipient [xxx] --sign --local-user [clientPrivateKey] --passphrase [clientPassphrase] --output “[outFilename.txt.asc]” “[inFilename.txt]”

    The java service returned this error
    gpg: cannot open `/dev/tty’: No such device or address

    Any guidance or suggestion on how to get PGP encryption with the option of --amour and --passphrase working under code would be appreciated.


    #Integration-Server-and-ESB
    #webMethods
    #Flow-and-Java-services