javamacosnotarize

Notarize existing Java application for MacOS Catalina


I distribute a Java application for MacOS, it is developer signed but not notarized. Not really sure where to start with this since the documentation is so biased towards creating apps with Xcode that I do not use, but I just want the simplest way to notarize my app and then move on.

Reading the documentation I have a few concerns already:


Solution

  • Update as of 3rd Feb 2020 Apple have tightened the notarization requirements, answer rewritten.

    Note:I required the AdoptJdk Java 11.0.7 JRE, earlier versions did not work for me.

    These are my steps

    build.xml includes:

    <runtime dir="/Library/Java/JavaVirtualMachines/adoptopenjdk-11.jre/Contents/Home"/>
    

    buildosx.sh is

    #!/bin/bash
    #set -x
    
    cd /Users/paul/code/jthink/songkong
    sudo rm -fr /Applications/SongKong.app
    mvn -f pommacos.xml -DskipTests=true install
    rm -fr target/songkong-6.9
    unzip target/songkong-6.9-distribution.zip -d target
    ant
    export CODESIGN_ALLOCATE="/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/codesign_allocate"
    /usr/bin/codesign --timestamp --options runtime \
    --entitlements /Users/paul/code/jthink/songkong/songkong.entitlements \
    --sign "Developer ID Application: P Taylor" \
    --force --deep --verbose /Applications/SongKong.app
    /usr/bin/codesign -vvv --deep --strict /Applications/SongKong.app
    spctl -a -t exec -vv /Applications/SongKong.app
    cd /Users/paul/code/jthink/SongKong
    /usr/local/bin/dmgcanvas /Users/paul/code/jthink/SongKong/dmgCanvas_songkong.dmgCanvas \
     /Users/paul/songkong-osx.dmg \
     -v SongKong -identity "Developer ID Application: P Taylor" \
     -notarizationAppleID paultaylor@jthink.net \
     -notarizationPassword password \
     -notarizationPrimaryBundleID songkong
    

    SongKong entitlements file is:

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
    <plist version="1.0">
    <dict>
        <key>com.apple.security.cs.allow-jit</key>
        <true/>
        <key>com.apple.security.cs.allow-unsigned-executable-memory</key>
        <true/>
        <key>com.apple.security.cs.disable-executable-page-protection</key>
        <true/>
        <key>com.apple.security.cs.disable-library-validation</key>
        <true/>
        <key>com.apple.security.cs.allow-dyld-environment-variables</key>
        <true/>
    </dict>
    </plist>
    

    Note:I have also tried this with referring to AdoptJdk Java 11.0.7 JDK build.xml and that also builds without issue (although of course end up witha much larger dmg)