Jetzt verfügbar:  Berichte für DRACOONMehr Infos

Erstellen einer Download-Freigabe einer Datei in einem verschlüsselten Datenraum mittels C#

Kommentare

5 Kommentare

  • Offizieller Kommentar
    Avatar
    Michael Netter

    Dear Klaus,

    As it states in the debugInfo message, it seems that you are sending an invalid JSON string. 

    In particular,

    • in line 3, there is a redundant double quote: "name":"XXX_TEST_KR.txt"",
    • in line 14, there is a double quote: "publicKeyContainer"":{

    Kind regards,
    Michael

    Aktionen für Kommentare Permalink
  • Avatar
    Klaus Rumpenhorst

    Good morning,

    The double quotes are only transmission errors. I am using the Newtonsoft.Json Functions to serialize the JSON-Strings.

    So, the double quotes are not the Problem. Do i have to encryp / decrypt the Private Key and / or the Public Key and / or the key of fileKey?

     

    Here is an example of the body I sent:

    {application/x-www-form-urlencoded=
     {
        "nodeId":5403,
        "name":" (TheFileName) ",
        "expiration":
            {
            "enableExpiration":true,
            "expireAt":"2020-09-22T09:50:16.0686736+02:00"
            },
        "keyPair":
            {
            "privateKeyContainer":
                {
                "version":"A",
                "privateKey":"-----BEGIN ENCRYPTED PRIVATE KEY-----\r\n (MyPrivateKey) \r\n-----END ENCRYPTED PRIVATE KEY-----"
                },
            "publicKeyContainer":
                {
                "version":"A",
                "publicKey":"-----BEGIN PUBLIC KEY-----\r\n (MyPublicKey) \r\n-----END PUBLIC KEY-----"
                }
            },
        "fileKey":
            {
            "key":" (TheActualFileKey) ",
            "iv":" (TheActualIV) ",
            "version":"A",
            "tag":" (TheActualTag) "
            }
        }
    }

    What's wrong or what's missing?

    Regards

    Klaus Rumpenhorst

    0
    Aktionen für Kommentare Permalink
  • Avatar
    DAVISOL - Sebastian Hübner

    Hi Klaus,

    According to your snippet you're sending the JSON body as HTML form data (application/x-www-form-urlencoded). Please note that all optional body data sent to the DRACOON API must use the "application/json" format. This is what the official DRACOON C# SDK is doing:

    private void SetGeneralRestValues(IRestRequest request, bool requiresAuth, object optionalJsonBody = null) {
    if (requiresAuth) {
    request.AddHeader(ApiConfig.AuthorizationHeader, _auth.BuildAuthString());
    }

    if (optionalJsonBody != null) {
    // This is the important line: Sending optional body as "application/json"
    request.AddParameter("application/json", JsonConvert.SerializeObject(optionalJsonBody), ParameterType.RequestBody);
    }

    request.ReadWriteTimeout = _client.HttpConfig.ReadWriteTimeout;
    request.Timeout = _client.HttpConfig.ConnectionTimeout;
    }

    As always, it's a good idea to use Swagger to test API calls and their response (https://my.dracoon.team/api/, click the Authorize button at the beginning of the Swagger page to enable inline request execution against your DRACOON). And of course, you're free to use the official DRACOON SDKs (https://github.com/dracoon/), which may abstract some of the common issues occurring when talking to the DRACOON API.

    HTH,
    Sebastian

    0
    Aktionen für Kommentare Permalink
  • Avatar
    Klaus Rumpenhorst

    Hello,

    1)
    I am sorry, but it's still not working; I get always the message error:

    "{"code":400,"message":"Bad Request","debugInfo":"JSON parse error.","errorCode":null}"

    I compared my JSON string with the curl output of the Swagger and I found no errors. In Swagger it's working fine.

    This is what i am sending:

    {
    "nodeId":5493,
    "name":"test_0001",
    "expiration":
    {
    "enableExpiration":true,
    "expireAt":"2020-09-23T11:06:52.8099345+02:00"
    },
    "keyPair":
    {
    "privateKeyContainer":
    {
    "version":"A",
    "privateKey":"-----BEGIN ENCRYPTED PRIVATE KEY----- (MyPrivateKey) -----END ENCRYPTED PRIVATE KEY-----"
    },
    "publicKeyContainer":
    {
    "version":"A",
    "publicKey":"-----BEGIN PUBLIC KEY----- (MyPublicKey) -----END PUBLIC KEY-----"
    }
    },
    "fileKey":
    {
    "key":" (key of the file) ",
    "iv":" (IV of the file) ",
    "version":"A",
    "tag":" (tag of the file) "
    }
    }

    2)
    Because I can't set a password for the encrypted download share, the users are not able to download the file!

    Please provide a workflow for creating encrypted download shares.

    Thanks.

    Regards,
    Klaus

    0
    Aktionen für Kommentare Permalink
  • Avatar
    Florian Scheuer

    Hi Klaus,

    Regarding your issue #2:

    You cannot set a password for encrypted download shares. This is a client-side cryptographic password that is applied only at the client side and must never be sent to the back-end (client-side encryption). I strongly recommend using our C# SDK für cryptographic purposes.

    Cheers,
    Florian

    0
    Aktionen für Kommentare Permalink

Bitte melden Sie sich an, um einen Kommentar zu hinterlassen.