MacOS App Signing and Notarizing lazarus / 33-macOS - Mac OS X ---------------------------------------------------------------------- axisdj · 2020-07-24 13:37 I wonder if any here have successfully got a MACos app signed. I have battled with it for a few days and keep running into problems. I have read over and over all the wiki's and attempted each step by step. here are my questions: 1. many of the docs and tools require different certificates, when downloading from Apple site they are very hard to deciefer 2. I got to the point where I was able to sign an app, partially but it broke the app because if hardened the bundle  ( I ship 3rd party dynlibs ) 3. I then tried entitlements but that did not seem to work I tried this: https://gitlab.com/ccrdude/lazarus-mac-application- wizard, again I got the app to sign but it broke functionality and the Gatekeeper says Unnotarized Developer ID. I know I may not have posted enough detail to help in my current situation, but if anyone has been through this and has any insight or advice it would be greatly appreciated. I also had a very frustrating instance where I placed the proper incs file and edited the plist, but the icon did not show(Even reboots did not work) until I created the dmg and dragged it out of the mounted drive.  Sorry about the rant just looking for guidance. ---------------------------------------------------------------------- ASBzone · 2020-07-24 15:59 Quote from: axisdj on July 24, 2020, 03:37:00 pmI wonder if any here have successfully got a MACos app signed. I have battled with it for a few days and keep running into problems. I have read over and over all the wiki's and attempted each step by step. ... Sorry about the rant just looking for guidance. I have zero experience with code signing on the Apple platforms, but have done it repeatedly for Windows. One of the most helpful vendors in terms of documentation and tools was DigiCert, and they offer some guidance for MacOS code signing.  Perhaps it will help you. https://www.digicert.com/kb/code-signing/mac-os-codesign-tool.htm Also: https://developer.apple.com/developer-id/ ---------------------------------------------------------------------- trev · 2020-07-25 11:33 Quote from: ASBzone on July 24, 2020, 05:59:43 pmOne of the most helpful vendors in terms of documentation and tools was DigiCert, and they offer some guidance for MacOS code signing.  Perhaps it will help you. https://www.digicert.com/kb/code-signing/mac-os-codesign-tool.htm Also: https://developer.apple.com/developer-id/ Beware: only Apple developer certificates can be used to code sign Mac applications. See Apple Developer Certificates,  Codesigning for macOS and Notiarization for macOS 10.14.5+. ---------------------------------------------------------------------- ChrisR · 2020-07-25 18:30 Ryan Joseph helped my work out App Notarization. I tried to describe details here   https://github.com/neurolabusc/NotarizeFPC The bash script below provides a skeleton for notarizing a MacOS app. You need to set up the first few lines to provide specific details regarding your application. It is remarkable that this process is so convoluted and poorly documented. One would think that the worlds most valuable company could invest in developing nice wrappers and clear documentation for this process. At least Xcode hides most of these issues from developers... Code: Bash  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i #APP_NAME# name of application, e.g. MyApp.appAPP_NAME=MyApp#APP_DIR# folder with App and other files, typically includes executable and symbolic link to applications folder:#  /Users/chris/MyApp/MyApp.app#  /Users/chris/MyApp/Applications #ln -s /Applications ApplicationsAPP_DIR=/Users/chris/#DEV_NAME# Name of Apple DeveloperDEV_NAME=Chris Robin#APP_SPECIFIC_PASSWORD# Specific password for application, created on Apple Web SiteAPP_SPECIFIC_PASSWORD=abcd- abcd-abcd-abcd cd ~/Neuro/${APP_NAME}  #https://stackoverflow.com/ques tions/2870992/automatic-exit-from-bash-shell-script-on-error# terminate on errorset -e xattr -cr ${APP_NAME}.app echo "Code signing ${APP_NAME}..."#2018 codesign -s "Developer ID Application: Christopher Rorden"  MRIcroGL.appcodesign -vvv --force --deep --strict --options=runtime --timestamp  -s "Developer ID Application: ${DEV_NAME}" ${APP_NAME}.appcodesign -vvvv --deep --strict ${APP_NAME}.appcodesign -dv --verbose=4 ${APP_NAME}.app cd ..# Clean up temporary filesrm -f ${APP_NAME}_macOS.dmgrm -f upload_log_file.txtrm -f request_log_file.txtrm -f log_file.txt hdiutil create -volname ${APP_NAME} -srcfolder ${APP_DIR}${APP_NAME} -ov -format UDZO -layout SPUD -fs HFS+J  ${APP_NAME}_macOS.dmg  codesign -s "$CODE_SIGN_SIGNATURE" ${APP_NAME}_macOS.dmg# Notarizing with Apple... echo "Uploading..."xcrun altool --notarize-app -t osx --file ${APP_NAME}_macOS.dmg --primary-bundle-id com.mricro.${APP_NAME} -u $APPLE_ID_USER -p $APP_SPECIFIC_PASSWORD --output-format xml > upload_log_file.txt # WARNING: if there is a 'product-errors' key in upload_log_file.txt something went wrong# we could parse it here and bail but not sure how to check for keys existing with PListBuddy# /usr/libexec/PlistBuddy -c "Print :product-errors:0:message" upload_log_file.txt # now we need to query apple's server to the status of notarization# when the "xcrun altool --notarize-app" command is finished the output plist# will contain a notarization- upload->RequestUUID key which we can use to check statusecho "Checking status..."sleep 20REQUEST_UUID=`/usr/libexec/PlistBuddy -c "Print :notarization-upload:RequestUUID" upload_log_file.txt`while true; do  xcrun altool --notarization-info $REQUEST_UUID -u $APPLE_ID_USER -p $APP_SPECIFIC_PASSWORD --output-format xml > request_log_file.txt  # parse the request plist for the notarization-info->Status Code key which will  # be set to "success" if the package was notarized  STATUS=`/usr/libexec/PlistBuddy -c "Print :notarization-info:Status" request_log_file.txt`  if [ "$STATUS" != "in progress" ]; then    break  fi  # echo $STATUS  echo "$STATUS"  sleep 10done # download the log file to view any issues/usr/bin/curl -o log_file.txt `/usr/libexec/PlistBuddy -c "Print :notarization-info:LogFileURL" request_log_file.txt` # stapleecho "Stapling..."xcrun stapler staple ${APP_NAME}_macOS.dmgxcrun stapler validate ${APP_NAME}_macOS.dmg open log_file.txt ---------------------------------------------------------------------- ASBzone · 2020-07-26 02:26 Quote from: ChrisR on July 25, 2020, 08:30:27 pmIt is remarkable that this process is so convoluted and poorly documented. One would think that the worlds most valuable company could invest in developing nice wrappers and clear documentation for this process. At least Xcode hides most of these issues from developers... Ha!  Most things pertaining to encryption are poorly documented and cumbersome to implement for many of these major, valuable corporations. Glad you got your issue worked out, though.   Thanks for the write up. ---------------------------------------------------------------------- ChrisR · 2020-07-27 13:41 This is another great resource for this topic:   https://wiki.freepascal.org/Notarization_for_macOS_10.14.5%2B