投稿済み Tue, 18 Jun 2019 12:30:36 GMT 、投稿者 Romain Amoudjayan
Hello
I've made the following script in php in order to generate the url integration from an extranet.
Despite many researches, i can't find what is wrong. I always get the error message "DocuWare.Gapi.Utils.Web.DWIntegration.EX_INVALID_PASS_PHRASE".

I've tried to compare my results with the application URL creator but i never get the same url.

I'm not sure that my code is correct to hash the passphrase and split it to get the key and iv.

Any help would be very appreciated. Thank you
 
<?php
//script php to generate url integration for docuware

//hash passphrase with sha512 and get key and iv    ( http://help.docuware.com/en/#b64090t60297n89509 )
$passphrase = hash('sha512', 'xxxxx');
$encryption_key  = substr($passphrase,0,32);
$iv = substr($passphrase,32,16);
echo "Passphrase hash: $passphrase\n";
echo "encryption_key: $encryption_key\n";
echo "iv: $iv\n";

//create parameters string to encrypt ( http://help.docuware.com/en/#b64090t61532n89494 )
//p=D for Download
$param = '&p=D';        
//Docuware login in base64
$lc = 'User=xxx\nPwd=xxx';    
$lc = convertToUrlTokenFormat(base64_encode($lc));
$param = $param . '&lc=' . $lc;
//fc=guid of the concerned file cabinet
$param = $param . '&fc=xxx';    
//request in base64
$q = '[N__DOCUMENT]=xxx';    
$q = convertToUrlTokenFormat(base64_encode($q));
$param = $param . '&q=' . $q ;
//download type
$param = $param . '&dt=Download';    

echo "Before encryption: $param\n";

// Encrypt $param using aes-256-cbc cipher with the given encryption key and iv
// The 0 gives us the default options, but can be changed to OPENSSL_RAW_param or OPENSSL_ZERO_PADDING
$encrypted = openssl_encrypt($param, 'aes-256-cbc', $encryption_key, 0, $iv);
echo "Encrypted: $encrypted\n";

//Encrypted paramters string encrypted again in base64 (see https://support.docuware.com/fr-fr/knowledgebase/article/KBA-35664 )
$encryptedbase64 = convertToUrlTokenFormat(base64_encode($encrypted));
echo "EncryptedBase64: $encryptedbase64\n\n";

$url = 'http://xxx/DocuWare/Platform/WebClient/1/Integration?&ep=' . $encryptedbase64;
echo "URL: $url\n";
    
function convertToUrlTokenFormat($val)
{
    $padding = substr_count($val, '=');
    $val = str_replace('=', '', $val);
    $val .= $padding;
    $val = str_replace('+', '-', str_replace('/', '_', $val));
    return $val;
}
?>
投稿済み Tue, 18 Jun 2019 12:31:36 GMT 、投稿者 Matthias Wieland DocuWare Europe GmbH Sr. Director Support EMEA
Dear Romain Amoudjayan! It looks like the Community cannot answer your question. Thats why we have opened a Support Request with the Number SR-69877-N4K5V for you. A Software Support Specialist will contact you directly to follow up. We will update this thread with the solution as soon as we have solved the Support Request. With Best Regards, DocuWare Support Team
投稿済み Sat, 11 Apr 2020 18:09:08 GMT 、投稿者 Aren Slootweg Developer
Hello Romain,

With the new update of Docuware 7.2 it no longer allowed to send the credentials only base64 encoded in the URL.
So I need to use the passphrase also to encode the complete URL.

Can you give some feedback how your question is answered by the Docuware support Team, or do you have a working solution ?

Kind regards,

Aren
投稿済み Tue, 14 Apr 2020 07:56:45 GMT 、投稿者 Romain Amoudjayan

Hello

No, it has never worked with PHP.

With the help of the support, i've tried to create a webservice in .Net, it worked locally, but not from an external access. I put this topic in standy for the moment.

Regards

Romain

投稿済み Tue, 14 Apr 2020 15:52:34 GMT 、投稿者 Aren Slootweg Developer
Hello Romain,

I asked some help at Docuware , Florian M. was able to help me out.

The passhrase needs to be utf8 encoded and the hash needs an extra parameter, set to true, needed for raw output 

$key = utf8_encode('password1234');
$passphrase = hash('sha512', $key, true);

Then one more change:
$encrypted = openssl_encrypt($param, 'aes-256-cbc', $encryption_key, 0, $iv);

Change the 0 to OPENSSL_RAW_DATA

$encrypted = openssl_encrypt($param, 'aes-256-cbc', $encryption_key, OPENSSL_RAW_DATA, $iv);

For me it works now! (-:

Hope it helps you also!

 
投稿済み Wed, 15 Apr 2020 08:35:43 GMT 、投稿者 Romain Amoudjayan
Hello Aren

Thanks a lot for this feedback. With these modifications, the result seems to work effectively!
I'll try to make further tests.

Thank you

フォーラムに投稿するためにはログインが必要です。