verify signature is not working

Comments

14 comments

  • Avatar
    Thomas Gurung

    Hi Alberto,

    Thank you for reaching out.

    So the code looks fine to me. 

    Can you confirm the verify signature is returning false for every notification you receive? 

    Also, can you confirm you are retrieving the timestamp from the response headers?

    I'm looking forward to your response.

    Kind Regards,
    Thomas

     
    
    
    0
    Comment actions Permalink
  • Avatar
    CloudAccount WARDA

    Hi Thomas,

     

    Yes I'm confirming that false is returning for every request for our costumer for wich I put the JSON.

     

    I'm reading the following headers:

    X-Cld-Signature
    X-Cld-Timestamp


    Alberto

     

    0
    Comment actions Permalink
  • Avatar
    Thomas Gurung

    Hi Alberto,

    Thanks for confirming and apologies for back late.

    I'm looking further so I will update you asap.

    Please let me know if you have any other questions or queries.

    Kind Regards,
    Thomas

    0
    Comment actions Permalink
  • Avatar
    Thomas Gurung

    Hi Alberto,

    Thanks for your patience.

    So it appears in the body, you are escaping the double quotes three times and this is most likely causing the signature mismatch.

    You should only need to escape the double quote once e.g.

    "{\"notification_type\":\"upload\",\"timestamp\":\"2022-09-05T12:40:29+00:00\",\"request_id\":\"b88ed9317f4d57df881cabe1c58e884a\",\"asset_id\":\"9061b752b50dd8fae02000cbc15562bc\",\"public_id\":\"test/seecommerce/original/202B0021T301-CE947-R\",\"version\":1662381623,\"version_id\":\"6cec0742c334ceb2891b791dc083681e\",\"width\":1571,\"height\":2000,\"format\":\"jpg\",\"resource_type\":\"image\",\"created_at\":\"2022-07-07T08:27:16Z\",\"tags\":[],\"pages\":1,\"bytes\":1158806,\"type\":\"upload\",\"etag\":\"ca50260a15fd4b7c753429ff28766137\",\"placeholder\":false,\"url\":\"http://media.brunellocucinelli.com/image/upload/v1662381623/test/seecommerce/original/202B0021T301-CE947-R.jpg\",\"secure_url\":\"https://media.brunellocucinelli.com/image/upload/v1662381623/test/seecommerce/original/202B0021T301-CE947-R.jpg\",\"folder\":\"test/seecommerce/original\",\"access_mode\":\"public\",\"faces\":[],\"image_metadata\":{\"CodedCharacterSet\":\"UTF8\",\"ApplicationRecordVersion\":\"4\",\"TimeCreated\":\"16:23:35+00:00\",\"DigitalCreationDate\":\"2020:06:29\",\"ImageWidth\":\"1571\",\"ImageHeight\":\"2000\",\"BitsPerSample\":\"8 8 8\",\"Compression\":\"LZW\",\"PhotometricInterpretation\":\"RGB\",\"Make\":\"Canon\",\"Model\":\"Canon EOS 5D Mark III\",\"Orientation\":\"Horizontal (normal)\",\"SamplesPerPixel\":\"3\",\"XResolution\":\"72\",\"YResolution\":\"72\",\"PlanarConfiguration\":\"Chunky\",\"ResolutionUnit\":\"inches\",\"Software\":\"Adobe Photoshop CS6 (Windows)\",\"ModifyDate\":\"2020:07:21 09:09:49\",\"ExposureTime\":\"1/125\",\"FNumber\":\"16.0\",\"ExposureProgram\":\"Manual\",\"ISO\":\"100\",\"SensitivityType\":\"Recommended Exposure Index\",\"RecommendedExposureIndex\":\"100\",\"ExifVersion\":\"0230\",\"DateTimeOriginal\":\"2020:06:29 16:23:35\",\"CreateDate\":\"2020:06:29 16:23:35\",\"ShutterSpeedValue\":\"1/125\",\"ApertureValue\":\"16.0\",\"ExposureCompensation\":\"0\",\"SubjectDistance\":\"0 m\",\"MeteringMode\":\"Multi-segment\",\"Flash\":\"Off, Did not fire\",\"FocalLength\":\"70.0 mm\",\"SubSecTimeOriginal\":\"60\",\"SubSecTimeDigitized\":\"60\",\"ColorSpace\":\"sRGB\",\"ExifImageWidth\":\"1571\",\"ExifImageHeight\":\"2000\",\"FocalPlaneXResolution\":\"3942.505127\",\"FocalPlaneYResolution\":\"3950.617188\",\"FocalPlaneResolutionUnit\":\"inches\",\"FileSource\":\"Digital Camera\",\"SceneType\":\"Directly photographed\",\"CustomRendered\":\"Normal\",\"ExposureMode\":\"Manual\",\"WhiteBalance\":\"Manual\",\"SceneCaptureType\":\"Standard\",\"SerialNumber\":\"083024003753\",\"LensInfo\":\"24-70mm f/?\",\"LensModel\":\"Canon EF 24-70mm f/2.8L USM\",\"LensSerialNumber\":\"0000000000\",\"ThumbnailOffset\":\"1026\",\"ThumbnailLength\":\"2485\",\"XMPToolkit\":\"Adobe XMP Core 5.3-c011 66.145661, 2012/02/06-14:56:27\",\"CreatorTool\":\"Adobe Photoshop CC 2017 (Macintosh)\",\"MetadataDate\":\"2020:07:21 09:09:49+02:00\",\"Lens\":\"Canon EF 24-70mm f/2.8L USM\",\"FlashCompensation\":\"0\",\"Firmware\":\"Firmware Version 1.3.5\",\"ApproximateFocusDistance\":\"0\",\"DateCreated\":\"2020:06:29 16:23:35.006\",\"LegacyIPTCDigest\":\"D40FE785184DBB6FB5BF7A7ECD8E78A8\",\"ColorMode\":\"RGB\",\"ICCProfileName\":\"sRGB IEC61966-2.1\",\"History\":\"2020-07-01T11:58:39+07:00\\tFile 202B0021T301CE947_SLr_UC269212.jpg opened\\n2020-07-01T12:02:15+07:00\\tFile 202B0021T301CE947_SLr_UC269212.tif saved\\n2020-07-01T14:03:11+07:00\\tFile 202B0021T301CE947_SLr_UC269212.tif saved\",\"DocumentID\":\"adobe:docid:photoshop:8e9a7a9c-e21f-ac4a-a50e-8b1d866d3a91\",\"InstanceID\":\"xmp.iid:F6A7E22021CBEA11B638B4A2589ABD39\",\"OriginalDocumentID\":\"86A51DEDCD26006221E7A13DA8F0EE2B\",\"Format\":\"image/jpeg\",\"HistoryAction\":\"saved, converted, derived, saved, saved, converted, derived, saved\",\"HistoryInstanceID\":\"xmp.iid:93FFFFF42B2068118083C9347BD6D104, xmp.iid:94FFFFF42B2068118083C9347BD6D104, xmp.iid:F5A7E22021CBEA11B638B4A2589ABD39, xmp.iid:F6A7E22021CBEA11B638B4A2589ABD39\",\"HistoryWhen\":\"2020:07:01 12:02:15+07:00, 2020:07:01 12:02:15+07:00, 2020:07:21 09:09:49+02:00, 2020:07:21 09:09:49+02:00\",\"HistorySoftwareAgent\":\"Adobe Photoshop CS6 (Macintosh), Adobe Photoshop CS6 (Macintosh), Adobe Photoshop CS6 (Windows), Adobe Photoshop CS6 (Windows)\",\"HistoryChanged\":\"/, /, /, /\",\"HistoryParameters\":\"from image/jpeg to image/tiff, converted from image/jpeg to image/tiff, from image/tiff to image/jpeg, converted from image/tiff to image/jpeg\",\"DerivedFromInstanceID\":\"xmp.iid:F5A7E22021CBEA11B638B4A2589ABD39\",\"DerivedFromDocumentID\":\"adobe:docid:photoshop:8e9a7a9c-e21f-ac4a-a50e-8b1d866d3a91\",\"DerivedFromOriginalDocumentID\":\"86A51DEDCD26006221E7A13DA8F0EE2B\",\"IPTCDigest\":\"c70df291a3b4f547ccc4ae94877fb195\",\"DisplayedUnitsX\":\"inches\",\"DisplayedUnitsY\":\"inches\",\"PrintStyle\":\"Centered\",\"PrintPosition\":\"0 0\",\"PrintScale\":\"1\",\"GlobalAngle\":\"30\",\"GlobalAltitude\":\"30\",\"URL_List\":\"\",\"SlicesGroupName\":\"ps14876_8D7BCDB\",\"NumSlices\":\"1\",\"PixelAspectRatio\":\"1\",\"HasRealMergedData\":\"Yes\",\"WriterName\":\"Adobe Photoshop\",\"ReaderName\":\"Adobe Photoshop CS6\",\"PhotoshopQuality\":\"11\",\"PhotoshopFormat\":\"Standard\",\"ProgressiveScans\":\"3 Scans\",\"ProfileDescription\":\"sRGB IEC61966-2.1\",\"Colorspace\":\"RGB\",\"DPI\":\"72\"},\"colors\":[[\"#D2C6B4\",87.3],[\"#D3D3CD\",9.3]],\"predominant\":{\"google\":[[\"gray\",87.3],[\"white\",9.3]],\"cloudinary\":[[\"white\",96.6]]},\"phash\":\"264fd8cc89cd9627\",\"coordinates\":{\"faces\":[]},\"illustration_score\":0.0,\"semi_transparent\":false,\"grayscale\":false,\"quality_analysis\":{\"focus\":1.0},\"original_filename\":\"72baa2e7-2dd7-42b6-9ae0-dabd63ae3126\"}"

    Please try it with that and let me know how you get on.

    Please let me know if you have any other questions or queries.

    Kind Regards,
    Thomas

    0
    Comment actions Permalink
  • Avatar
    CloudAccount WARDA

    Hi Thomas, the triple quotes i think that was created by my IDE.

    So for this account the validation is working for the following request:

    private val demoBody =
    "{\"notification_type\":\"upload\",\"timestamp\":\"2022-06-21T12:21:37+00:00\",\"request_id\":\"b7047810c03830f4b6da7b6a1b8bb293\",\"asset_id\":\"92c14d2fd9dd55c415534280d7b8dac2\",\"public_id\":\"test/digitalassets/original/dd357e7a-9375-4e90-bd09-d8a9f9f1dd2f\",\"version\":1655814095,\"version_id\":\"10d567813810491a46df434bbb547527\",\"width\":1045,\"height\":1600,\"format\":\"jpg\",\"resource_type\":\"image\",\"created_at\":\"2022-06-21T12:21:35Z\",\"tags\":[],\"bytes\":129435,\"type\":\"upload\",\"etag\":\"d8a0462b16a515a276a157294e48458f\",\"placeholder\":false,\"url\":\"http://res.cloudinary.com/test-seecommerce/image/upload/v1655814095/test/digitalassets/original/dd357e7a-9375-4e90-bd09-d8a9f9f1dd2f.jpg\",\"secure_url\":\"https://res.cloudinary.com/test-seecommerce/image/upload/v1655814095/test/digitalassets/original/dd357e7a-9375-4e90-bd09-d8a9f9f1dd2f.jpg\",\"folder\":\"test/digitalassets/original\",\"access_mode\":\"public\",\"original_filename\":\"d1368628-2603-4d99-b785-957945d1e560\"}"
    private val demoTimestamp = "1655814099"
    private val demoSignature = "0b23323227ecd4f1f5f22400c75bf825f2a639e7"

    for my customer we're trying to validate with the following data and the Cloudinary SDK is returning false.

     

    private val customerBody =
    "{\"notification_type\":\"upload\",\"timestamp\":\"2022-09-14T08:19:31+00:00\",\"request_id\":\"b46c8e28e3f65de16ab5f57faf2c6c5c\",\"asset_id\":\"e5142c67f45870d977780747d249b53c\",\"public_id\":\"dev/seecommerce/original/202B0021T301-CE947-F\",\"version\":1663143564,\"version_id\":\"9646467baa0de08604a3512f47616dd5\",\"width\":1571,\"height\":2000,\"format\":\"jpg\",\"resource_type\":\"image\",\"created_at\":\"2022-09-14T08:19:24Z\",\"tags\":[],\"bytes\":1224089,\"type\":\"upload\",\"etag\":\"38d351d7871ab92ef9f7a36006a9f8ee\",\"placeholder\":false,\"url\":\"http://media.brunellocucinelli.com/image/upload/v1663143564/dev/seecommerce/original/202B0021T301-CE947-F.jpg\",\"secure_url\":\"https://media.brunellocucinelli.com/image/upload/v1663143564/dev/seecommerce/original/202B0021T301-CE947-F.jpg\",\"folder\":\"dev/seecommerce/original\",\"access_mode\":\"public\",\"image_metadata\":{\"CodedCharacterSet\":\"UTF8\",\"ApplicationRecordVersion\":\"4\",\"TimeCreated\":\"16:22:25+00:00\",\"DigitalCreationDate\":\"2020:06:29\",\"ImageWidth\":\"1571\",\"ImageHeight\":\"2000\",\"BitsPerSample\":\"8 8 8\",\"Compression\":\"LZW\",\"PhotometricInterpretation\":\"RGB\",\"Make\":\"Canon\",\"Model\":\"Canon EOS 5D Mark III\",\"Orientation\":\"Horizontal (normal)\",\"SamplesPerPixel\":\"3\",\"XResolution\":\"72\",\"YResolution\":\"72\",\"PlanarConfiguration\":\"Chunky\",\"ResolutionUnit\":\"inches\",\"Software\":\"Adobe Photoshop CS6 (Windows)\",\"ModifyDate\":\"2020:07:21 09:09:39\",\"ExposureTime\":\"1/125\",\"FNumber\":\"16.0\",\"ExposureProgram\":\"Manual\",\"ISO\":\"100\",\"SensitivityType\":\"Recommended Exposure Index\",\"RecommendedExposureIndex\":\"100\",\"ExifVersion\":\"0230\",\"DateTimeOriginal\":\"2020:06:29 16:22:25\",\"CreateDate\":\"2020:06:29 16:22:25\",\"ShutterSpeedValue\":\"1/125\",\"ApertureValue\":\"16.0\",\"ExposureCompensation\":\"0\",\"SubjectDistance\":\"0 m\",\"MeteringMode\":\"Multi-segment\",\"Flash\":\"Off, Did not fire\",\"FocalLength\":\"70.0 mm\",\"SubSecTimeOriginal\":\"59\",\"SubSecTimeDigitized\":\"59\",\"ColorSpace\":\"sRGB\",\"ExifImageWidth\":\"1571\",\"ExifImageHeight\":\"2000\",\"FocalPlaneXResolution\":\"3942.505127\",\"FocalPlaneYResolution\":\"3950.617188\",\"FocalPlaneResolutionUnit\":\"inches\",\"FileSource\":\"Digital Camera\",\"SceneType\":\"Directly photographed\",\"CustomRendered\":\"Normal\",\"ExposureMode\":\"Manual\",\"WhiteBalance\":\"Manual\",\"SceneCaptureType\":\"Standard\",\"SerialNumber\":\"083024003753\",\"LensInfo\":\"24-70mm f/?\",\"LensModel\":\"Canon EF 24-70mm f/2.8L USM\",\"LensSerialNumber\":\"0000000000\",\"ThumbnailOffset\":\"1026\",\"ThumbnailLength\":\"2712\",\"XMPToolkit\":\"Adobe XMP Core 5.3-c011 66.145661, 2012/02/06-14:56:27\",\"CreatorTool\":\"Adobe Photoshop CC 2017 (Macintosh)\",\"MetadataDate\":\"2020:07:21 09:09:39+02:00\",\"Lens\":\"Canon EF 24-70mm f/2.8L USM\",\"FlashCompensation\":\"0\",\"Firmware\":\"Firmware Version 1.3.5\",\"ApproximateFocusDistance\":\"0\",\"DateCreated\":\"2020:06:29 16:22:25.059\",\"LegacyIPTCDigest\":\"FC9B262B022BCA19D69E340FFE0203A7\",\"ColorMode\":\"RGB\",\"ICCProfileName\":\"sRGB IEC61966-2.1\",\"History\":\"2020-07-01T10:45:55+07:00\\tFile 202B0021T301CE947_SLf_UC269198.jpg opened\\n2020-07-01T10:55:56+07:00\\tFile _202B0021T301CE947_SLf_UC269198D250CE1F7C160B5591F52BCA9E77BBB8.psb saved\\n2020-07-01T11:25:59+07:00\\tFile _202B0021T301CE947_SLf_UC269198D250CE1F7C160B5591F52BCA9E77BBB8.psb saved\\n2020-07-01T11:54:56+07:00\\tFile 202B0021T301CE947_SLf_UC269198.tif saved\\n2020-07-01T14:03:27+07:00\\tFile 202B0021T301CE947_SLf_UC269198.tif opened\\n2020-07-01T14:06:11+07:00\\tFile 202B0021T301CE947_SLf_UC269198.tif saved\",\"DocumentID\":\"adobe:docid:photoshop:b2729241-6a33-154e-893e-ab6b91d2b6fc\",\"InstanceID\":\"xmp.iid:A28A0B1A21CBEA11A45CFC46BCD36F40\",\"OriginalDocumentID\":\"A582795E5DDCE3F4790743E30B06752A\",\"Format\":\"image/jpeg\",\"HistoryAction\":\"saved, converted, derived, saved, saved, converted, derived, saved\",\"HistoryInstanceID\":\"xmp.iid:29A50E4A212068118083C9347BD6D104, xmp.iid:2AA50E4A212068118083C9347BD6D104, xmp.iid:A18A0B1A21CBEA11A45CFC46BCD36F40, xmp.iid:A28A0B1A21CBEA11A45CFC46BCD36F40\",\"HistoryWhen\":\"2020:07:01 11:54:56+07:00, 2020:07:01 11:54:56+07:00, 2020:07:21 09:09:39+02:00, 2020:07:21 09:09:39+02:00\",\"HistorySoftwareAgent\":\"Adobe Photoshop CS6 (Macintosh), Adobe Photoshop CS6 (Macintosh), Adobe Photoshop CS6 (Windows), Adobe Photoshop CS6 (Windows)\",\"HistoryChanged\":\"/, /, /, /\",\"HistoryParameters\":\"from image/jpeg to image/tiff, converted from image/jpeg to image/tiff, from image/tiff to image/jpeg, converted from image/tiff to image/jpeg\",\"DerivedFromInstanceID\":\"xmp.iid:A18A0B1A21CBEA11A45CFC46BCD36F40\",\"DerivedFromDocumentID\":\"adobe:docid:photoshop:b2729241-6a33-154e-893e-ab6b91d2b6fc\",\"DerivedFromOriginalDocumentID\":\"A582795E5DDCE3F4790743E30B06752A\",\"IPTCDigest\":\"757b10760355343c6c2ecf8f7d6e49b2\",\"DisplayedUnitsX\":\"inches\",\"DisplayedUnitsY\":\"inches\",\"PrintStyle\":\"Centered\",\"PrintPosition\":\"0 0\",\"PrintScale\":\"1\",\"GlobalAngle\":\"30\",\"GlobalAltitude\":\"30\",\"URL_List\":\"\",\"SlicesGroupName\":\"ps14883_14221AE9\",\"NumSlices\":\"1\",\"PixelAspectRatio\":\"1\",\"HasRealMergedData\":\"Yes\",\"WriterName\":\"Adobe Photoshop\",\"ReaderName\":\"Adobe Photoshop CS6\",\"PhotoshopQuality\":\"11\",\"PhotoshopFormat\":\"Standard\",\"ProgressiveScans\":\"3 Scans\",\"original_filename\":\"9ef2320e-b0c5-4847-8f1f-2cd8181fee15\"}"
    private val customerTimestamp = "1663143800"
    private val customerSignature = "87d668c49f154bb80934184de29e342f8196652f"



    So I get two questions:

    • Why here the validation is not working?
    • Why there are so many extra fields in my customer JSON?

    Best regards,

     

    Alberto

    0
    Comment actions Permalink
  • Avatar
    Thomas Gurung

    Hi Alberto,

    Thanks for getting back.

    I'm seeing a lot of 500 response from your webhook notification for that customer, this may not be the reason for the error but could you check if your endpoint is having any issues?

    Also, the reason why they have so many fields in the response is that they are using a default upload preset which has image_metadata enabled so extra data is included in the response. 

    I just did a test upload to that account and verification was true with the following data:

    body = "{\"notification_type\":\"upload\",\"timestamp\":\"2022-09-14T12:06:15+00:00\",\"request_id\":\"380165e89cc02c33cae9f244dbd3a201\",\"asset_id\":\"2ebedd507f9df6f30b124281881d7bbd\",\"public_id\":\"sample\",\"version\":1656655605,\"version_id\":\"4932ed07df1512a66ea88f510c5543dc\",\"width\":864,\"height\":576,\"format\":\"jpg\",\"resource_type\":\"image\",\"created_at\":\"2020-09-16T13:37:50Z\",\"tags\":[],\"pages\":1,\"bytes\":120253,\"type\":\"upload\",\"etag\":\"83340520d28b704ca4f4b019effb33dc\",\"placeholder\":false,\"url\":\"http://media.brunellocucinelli.com/image/upload/v1656655605/sample.jpg\",\"secure_url\":\"https://media.brunellocucinelli.com/image/upload/v1656655605/sample.jpg\",\"folder\":\"\",\"access_mode\":\"public\",\"overwritten\":true,\"faces\":[],\"image_metadata\":{\"JFIFVersion\":\"1.01\",\"ResolutionUnit\":\"inches\",\"XResolution\":\"100\",\"YResolution\":\"100\",\"Colorspace\":\"RGB\",\"DPI\":\"100\"},\"colors\":[[\"#56750E\",15.6],[\"#ABC564\",13.8],[\"#2A4004\",12.4],[\"#E51C42\",10.7],[\"#748F34\",10.3],[\"#122A02\",6.7],[\"#F26492\",3.8],[\"#FB86CD\",3.7],[\"#86050C\",3.7],[\"#C3CF6A\",3.6],[\"#838D36\",1.8],[\"#6F7A10\",1.6],[\"#F5AB0E\",1.3],[\"#FCCCEB\",1.0],[\"#372E05\",1.0],[\"#E3BF72\",0.9],[\"#D35614\",0.6],[\"#7A5810\",0.6],[\"#D4CD68\",0.5],[\"#85330C\",0.5],[\"#E29068\",0.5]],\"predominant\":{\"google\":[[\"green\",48.1],[\"brown\",16.0],[\"red\",15.0],[\"pink\",8.5],[\"yellow\",4.1],[\"orange\",2.7]],\"cloudinary\":[[\"olive\",43.1],[\"green\",19.1],[\"red\",15.0],[\"pink\",8.5],[\"yellow\",4.1],[\"orange\",2.7],[\"brown\",2.0]]},\"phash\":\"c9635a63eacf11c1\",\"coordinates\":{\"faces\":[]},\"illustration_score\":0.0,\"semi_transparent\":false,\"grayscale\":false,\"quality_analysis\":{\"focus\":0.5301076173782349},\"original_filename\":\"sample\"}"
    timestamp = 1663157188
    signature = 94e519fb02f2a3bdd8cb8d7acd5885458cf2dbd5

    Can you send me the full response headers and json body of the test you are doing before parsing the data?

    Thanks,

    Thomas

    0
    Comment actions Permalink
  • Avatar
    CloudAccount WARDA

    Hi Thomas,

     

    I tried with your same body, timesmap and signature but the SDK is returning to me false.

     

    I share some of our codes with the hopes that it can helps.


    This is our verifySignature method:

    override def verifySignature(body: String, timestamp: String, signature: String): ZIO[Any, Throwable, Boolean] = {
    for {
    _ <- ZIO.effect(
    logger.debug(
    s"CloudinaryClient.verifySignature with body: $body, timestamp $timestamp and signature $signature with apiSecret ${cloudinaryAccount.apiSecret.value}"
    )
    )
    signatureVerifier <- ZIO.effect(new NotificationRequestSignatureVerifier(cloudinaryAccount.apiSecret.value))
    result <- ZIO.effect(signatureVerifier.verifySignature(body, timestamp, signature))
    _ <- ZIO.effect(logger.debug(s"CloudinaryClient.verifySignature result $result"))
    } yield result
    }

     

    In the project we're using the Java SDK, with JDK 11 used by a Scala 2.12.15 project. These are the two dependencies that we're introducing inside:

    "com.cloudinary" % "cloudinary-core" % "1.32.2",
    "com.cloudinary" % "cloudinary-http44" % "1.32.2",

     

    This is the spec part that I written to test:

    "return true if the body is valid for the signature for customer Client" in {
    Runtime.default
    .unsafeRunToFuture(client.verifySignature(body, timestamp, signature))
    .future
    .futureValue shouldBe true
    }

    We created this wrapper here with this config to use for the verify and upload operations:

    final case class CloudinaryClient(tenant: TenantId, cloudinaryAccount: CloudinaryAccount)
    extends CDNClient
    with LazyLogging {

    private val client: Cloudinary = new Cloudinary(
    ObjectUtils.asMap(CloudName,
    cloudinaryAccount.cloudName.value,
    ApiKey,
    cloudinaryAccount.apiKey.value,
    ApiSecret,
    cloudinaryAccount.apiSecret.value,
    Secure,
    Boolean.box(true)
    )
    )


    Let me know if you needs some extra informations.

     

    Best regards,

     

    Alberto

    0
    Comment actions Permalink
  • Avatar
    Thomas Gurung

    Hi Alberto,

    Thanks for getting back.

    It's probably failing for you now because the valid_for time has elapsed, if you set it to `valid_for=86400` (24 hours) does it work?

    The code looks ok, it looks like you get the customers' API secret before validating so the issue most probably lies in the body you are sending, if it's not exactly the same as what we sent then validation will fail. 

    Can you confirm if body is being parsed through some middleware? For example, we've had cases where we send duration: 30.0 but on client side, the json parsing middleware being used was returning it as duration: 30.

    Could you also send us the full webhook notification and response headers before your app processes it? If it's valid this way then we know something in your app is causing the failure. 

    Kind Regards,
    Thomas 

    0
    Comment actions Permalink
  • Avatar
    CloudAccount WARDA

    Hi Thomas,

     

    I can confirm that we're using https://github.com/circe/circe for deserialize the entity.

    I'm going to provide the body I'm receiving from your system with all the details.

     

     

    Best regards

    0
    Comment actions Permalink
  • Avatar
    Thomas Gurung

    Hi Alberto,

    Thanks for getting back.

    I'm looking forward to your response.

    Kind Regards,
    Thomas

    0
    Comment actions Permalink
  • Avatar
    CloudAccount WARDA

    Hi Thomas,

     

    here some logs extracts from the api-gateway service that we're using. So before the request is coming into our system.

    This is the validation that's working:

    endpoint: aws_url:30021/cloudinaryNotification/DEMO/seecommerce/f24efe1f-0b36-4248-b4d4-991b46efe0b1?targetKey=dev/seecommerce/original/6RjdSIa7Bi8IN7Dj-111-B&userId=auth0%7C5dd40503f51b5c0f39c4c928

    json:

    {
        "notification_type": "upload",
        "timestamp": "2022-08-22T08:02:07+00:00",
        "request_id": "0a77d3d9b95a1e06bb959f47df2da6c4",
        "asset_id": "d57b356076a969d9689441361b09d799",
        "public_id": "dev/seecommerce/original/03wQdhpgGekH9OtW-111-F",
        "version": 1661155324,
        "version_id": "d689afa371f4a5d60d8834e8ccc2ff42",
        "width": 4000,
        "height": 5000,
        "format": "jpg",
        "resource_type": "image",
        "created_at": "2022-07-28T13:43:56Z",
        "tags": [],
        "bytes": 2349065,
        "type": "upload",
        "etag": "41b8bd035102d19881b607a9bf1e9f07",
        "placeholder": false,
        "url": "http://res.cloudinary.com/test-seecommerce/image/upload/v1661155324/dev/seecommerce/original/03wQdhpgGekH9OtW-111-F.jpg",
        "secure_url": "https://res.cloudinary.com/test-seecommerce/image/upload/v1661155324/dev/seecommerce/original/03wQdhpgGekH9OtW-111-F.jpg",
        "folder": "dev/seecommerce/original",
        "access_mode": "public",
        "overwritten": true,
        "original_filename": "7ccfcb82-fdb0-4195-9fbc-1bf6741869e9",
        "original_extension": "jpeg"
    }

     

    This instead is the details for the Json that we're not able to validate:

    endpoint: aws_url:30021/cloudinaryNotification/CUCINELLI/seecommerce/9ef2320e-b0c5-4847-8f1f-2cd8181fee15?targetKey=dev/seecommerce/original/202B0021T301-CE947-F&userId=9ee83a99-53e8-42f3-bf8b-ffcb13747d5a

     

    json:


    {
       "notification_type":"upload",
       "timestamp":"2022-09-16T08:20:10+00:00",
       "request_id":"be3922a9556873cc7a4d3758075aba73",
       "asset_id":"32f9fdf4cefbd33fc194e2e41ec8a972",
       "public_id":"dev/seecommerce/original/202B289LP106-C2005-F",
       "version":1663316402,
       "version_id":"b2e91ce9996e05a9b858fb6007e34b5b",
       "width":1571,
       "height":2000,
       "format":"jpg",
       "resource_type":"image",
       "created_at":"2022-09-16T08:20:02Z",
       "tags":[
          
       ],
       "pages":1,
       "bytes":1196296,
       "type":"upload",
       "etag":"a061988ab245a36dcbdfddf677609b82",
       "placeholder":false,
       "url":"http://media.brunellocucinelli.com/image/upload/v1663316402/dev/seecommerce/original/202B289LP106-C2005-F.jpg",
       "secure_url":"https://media.brunellocucinelli.com/image/upload/v1663316402/dev/seecommerce/original/202B289LP106-C2005-F.jpg",
       "folder":"dev/seecommerce/original",
       "access_mode":"public",
       "faces":[
          
       ],
       "image_metadata":{
          "CodedCharacterSet":"UTF8",
          "ApplicationRecordVersion":"4",
          "TimeCreated":"10:27:27+00:00",
          "DigitalCreationDate":"2020:10:02",
          "ImageWidth":"1571",
          "ImageHeight":"2000",
          "BitsPerSample":"8 8 8",
          "Compression":"LZW",
          "PhotometricInterpretation":"RGB",
          "Make":"Canon",
          "Model":"Canon EOS 5D Mark II",
          "Orientation":"Horizontal (normal)",
          "SamplesPerPixel":"3",
          "XResolution":"72",
          "YResolution":"72",
          "PlanarConfiguration":"Chunky",
          "ResolutionUnit":"inches",
          "Software":"Adobe Photoshop CS6 (Windows)",
          "ModifyDate":"2020:10:08 09:53:32",
          "ExposureTime":"1/125",
          "FNumber":"14.0",
          "ExposureProgram":"Manual",
          "ISO":"200",
          "ExifVersion":"0230",
          "DateTimeOriginal":"2020:10:02 10:27:27",
          "CreateDate":"2020:10:02 10:27:27",
          "ShutterSpeedValue":"1/125",
          "ApertureValue":"14.0",
          "ExposureCompensation":"0",
          "SubjectDistance":"0 m",
          "MeteringMode":"Multi-segment",
          "Flash":"Off, Did not fire",
          "FocalLength":"40.0 mm",
          "SubSecTimeOriginal":"97",
          "SubSecTimeDigitized":"97",
          "ColorSpace":"sRGB",
          "ExifImageWidth":"1571",
          "ExifImageHeight":"2000",
          "FocalPlaneXResolution":"3849.21167",
          "FocalPlaneYResolution":"3908.141846",
          "FocalPlaneResolutionUnit":"inches",
          "FileSource":"Digital Camera",
          "SceneType":"Directly photographed",
          "CustomRendered":"Normal",
          "ExposureMode":"Manual",
          "WhiteBalance":"Auto",
          "SceneCaptureType":"Standard",
          "SerialNumber":"320212795",
          "LensModel":"Canon EF 24-105mm f/4L IS USM",
          "ThumbnailOffset":"934",
          "ThumbnailLength":"2693",
          "XMPToolkit":"Adobe XMP Core 5.3-c011 66.145661, 2012/02/06-14:56:27",
          "Lens":"Canon EF 24-105mm f/4L IS USM",
          "FlashCompensation":"0",
          "Firmware":"Firmware Version 1.0.6",
          "ApproximateFocusDistance":"0",
          "DateCreated":"2020:10:02 10:27:27.097",
          "LegacyIPTCDigest":"C9DE62709307DC061208249FB8A16CF7",
          "ColorMode":"RGB",
          "ICCProfileName":"sRGB IEC61966-2.1",
          "CreatorTool":"Adobe Photoshop CC 2018 (Macintosh)",
          "MetadataDate":"2020:10:08 09:53:32+02:00",
          "DocumentID":"adobe:docid:photoshop:25855a77-ae53-f94c-b951-50819e7c0e90",
          "InstanceID":"xmp.iid:81C773523B09EB11B5D8E6C7487C7473",
          "OriginalDocumentID":"498322A09D3C2AF47455C790AD2BBEBF",
          "Format":"image/jpeg",
          "HistoryAction":"saved, converted, derived, saved, saved, converted, derived, saved",
          "HistoryInstanceID":"xmp.iid:EC5331C31D2068118083DD1CC5D40B4E, xmp.iid:ED5331C31D2068118083DD1CC5D40B4E, xmp.iid:80C773523B09EB11B5D8E6C7487C7473, xmp.iid:81C773523B09EB11B5D8E6C7487C7473",
          "HistoryWhen":"2020:10:03 06:00:59-07:00, 2020:10:03 06:00:59-07:00, 2020:10:08 09:53:32+02:00, 2020:10:08 09:53:32+02:00",
          "HistorySoftwareAgent":"Adobe Photoshop CS6 (Macintosh), Adobe Photoshop CS6 (Macintosh), Adobe Photoshop CS6 (Windows), Adobe Photoshop CS6 (Windows)",
          "HistoryChanged":"/, /, /, /",
          "HistoryParameters":"from image/jpeg to image/tiff, converted from image/jpeg to image/tiff, from image/tiff to image/jpeg, converted from image/tiff to image/jpeg",
          "DerivedFromInstanceID":"xmp.iid:80C773523B09EB11B5D8E6C7487C7473",
          "DerivedFromDocumentID":"adobe:docid:photoshop:25855a77-ae53-f94c-b951-50819e7c0e90",
          "DerivedFromOriginalDocumentID":"498322A09D3C2AF47455C790AD2BBEBF",
          "IPTCDigest":"d8e8e6809bddc3a67516b113ce2f1fab",
          "DisplayedUnitsX":"inches",
          "DisplayedUnitsY":"inches",
          "PrintStyle":"Centered",
          "PrintPosition":"0 0",
          "PrintScale":"1",
          "GlobalAngle":"30",
          "GlobalAltitude":"30",
          "URL_List":"",
          "SlicesGroupName":"ps14883_7B692607",
          "NumSlices":"1",
          "PixelAspectRatio":"1",
          "HasRealMergedData":"Yes",
          "WriterName":"Adobe Photoshop",
          "ReaderName":"Adobe Photoshop CS6",
          "PhotoshopQuality":"11",
          "PhotoshopFormat":"Standard",
          "ProgressiveScans":"3 Scans",
          "ProfileDescription":"sRGB IEC61966-2.1",
          "Colorspace":"RGB",
          "DPI":"72"
       },
       "colors":[
          [
             "#CEC2B1",
             73.7
          ],
          [
             "#B88254",
             19.9
          ],
          [
             "#9E683F",
             5.6
          ]
       ],
       "predominant":{
          "google":[
             [
                "gray",
                73.7
             ],
             [
                "orange",
                19.9
             ],
             [
                "brown",
                5.6
             ]
          ],
          "cloudinary":[
             [
                "gray",
                73.7
             ],
             [
                "brown",
                25.5
             ]
          ]
       },
       "phash":"d3c3f14e34cc3c32",
       "coordinates":{
          "faces":[
             
          ]
       },
       "illustration_score":0.0,
       "semi_transparent":false,
       "grayscale":false,
       "quality_analysis":{
          "focus":0.8767565488815308
       },
       "original_filename":"642a50c8-963a-43ad-8c30-ca8d4e734016"
    }

     

    Is it not possible to be called with already the json in one line? We're doing some transformation just to remove all the spaces using: 

    notification.noSpaces

    that's generating a String from our Json object.

    Best regards,

     

    Alberto

    0
    Comment actions Permalink
  • Avatar
    Thomas Gurung

    Hi Alberto,

    Thanks for getting back and apologies in the delay, for some reason I did not get alerted on your update. 

    I'm looking into it now so will get back to you asap.

    Thanks,
    Thomas

    0
    Comment actions Permalink
  • Avatar
    Thomas Gurung

    Hi Alberto,

    Thanks for waiting. 

    So the json data we sent looks fine, could you send me the timestamp and signature from the response headers as well for that? 

    You mentioned you removed spaces before converting to a string and this is probably what's causing the mismatch. 

    I would recommend just storing the raw json data from the response -> escape the double quotes -> then convert to string without performing any other parsing.

    I'm looking forward to your response.

    Kind Regards,
    Thomas

    0
    Comment actions Permalink
  • Avatar
    CloudAccount WARDA

    Hi Thomas,

     

    sorry but If I'm not removing the spaces the verify is not working also for the original json that's working.

     

    Is it not possibile to receive the json already without spaces in the request? It's this the reason why we'are doing that.

    Best regards,

     

    Alberto

    0
    Comment actions Permalink

Please sign in to leave a comment.