Re: SecStaticCodeCheckValidity fails when app is lauched from Terminal

2016-09-27 Thread Markus Spoettl

On 27/09/16 22:57, Chris Hanson wrote:

On Sep 27, 2016, at 1:54 PM, Markus Spoettl  wrote:


On 27/09/16 22:39, Chris Hanson wrote:

How are you getting the URL that you pass to represent your application?

Could it be that you’re constructing the URL from a relative path when run
from the command line, rather than the full path? (You can’t depend on being
run from any particular working directory.)


Not sure what you mean by URL, I'm merely executing the app's executable from the command line. Assuming 
the My.app bundle is located in "~/Projects/My/Debug", I cd into "~/Projects/My" and 
execute "./Debug/My.App/Contents/MacOS/My”.


I mean, how are you constructing the SecStaticCodeRef that you pass to 
SecStaticCodeCheckValidity()?


OK, here the full code:

CFStringRef reqStr = 

SecStaticCodeRef ref = NULL;
SecRequirementRef req = NULL;

CFURLRef bURL = CFBundleCopyBundleURL(CFBundleGetMainBundle());
OSStatus status = SecStaticCodeCreateWithPath(bURL, kSecCSDefaultFlags, );

if ((ref != NULL) && (status == noErr)) {
  status = SecRequirementCreateWithString(reqStr, kSecCSDefaultFlags, );

  if ((req != NULL) && (status == noErr)) {
// this fails
status = SecStaticCodeCheckValidity(ref, kSecCSCheckAllArchitectures, req);


Regards
Markus
--
__
Markus Spoettl
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: SecStaticCodeCheckValidity fails when app is lauched from Terminal

2016-09-27 Thread Chris Hanson
On Sep 27, 2016, at 1:54 PM, Markus Spoettl  wrote:
> 
> On 27/09/16 22:39, Chris Hanson wrote:
>> How are you getting the URL that you pass to represent your application?
>> 
>> Could it be that you’re constructing the URL from a relative path when run
>> from the command line, rather than the full path? (You can’t depend on being
>> run from any particular working directory.)
> 
> Not sure what you mean by URL, I'm merely executing the app's executable from 
> the command line. Assuming the My.app bundle is located in 
> "~/Projects/My/Debug", I cd into "~/Projects/My" and execute 
> "./Debug/My.App/Contents/MacOS/My”.

I mean, how are you constructing the SecStaticCodeRef that you pass to 
SecStaticCodeCheckValidity()?

  -- Chris



___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: SecStaticCodeCheckValidity fails when app is lauched from Terminal

2016-09-27 Thread Markus Spoettl

On 27/09/16 22:39, Chris Hanson wrote:

How are you getting the URL that you pass to represent your application?

Could it be that you’re constructing the URL from a relative path when run
from the command line, rather than the full path? (You can’t depend on being
run from any particular working directory.)


Not sure what you mean by URL, I'm merely executing the app's executable from 
the command line. Assuming the My.app bundle is located in 
"~/Projects/My/Debug", I cd into "~/Projects/My" and execute 
"./Debug/My.App/Contents/MacOS/My".


I'm starting the app from the command line in cases when I want to test a 
certain localization using the -AppleLanguages '(xx)' command line option, which 
is quite handy.


As I said this used to work fine, but now the code signing signature is being 
rejected. However, using the "open" command works fine for me.


Regards
Markus
--
__
Markus Spoettl
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: SecStaticCodeCheckValidity fails when app is lauched from Terminal

2016-09-27 Thread Chris Hanson
How are you getting the URL that you pass to represent your application?

Could it be that you’re constructing the URL from a relative path when run from 
the command line, rather than the full path? (You can’t depend on being run 
from any particular working directory.)

  -- Chris

> On Sep 26, 2016, at 2:44 AM, Markus Spoettl  wrote:
> 
> I'm using SecStaticCodeCheckValidity() to self check the signature of my own 
> app when it is launched. This works fine and always has.
> 
> All of a sudden, the call to SecStaticCodeCheckValidity() fails if (and only 
> if the application) is started from the Terminal. When I start the very same 
> app from the Dock or from the Finder the check succeeds (iow. the call 
> returns noErr).
> 
> I don't know exactly when it started failing. I only know it definitely 
> worked before on previous versions of El Capitan but now it no longer does (v 
> 10.11.6).
> 
> Any ideas?
> 
> Regards
> Markus
> -- 
> __
> Markus Spoettl
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/cmh%40me.com
> 
> This email sent to c...@me.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: SecStaticCodeCheckValidity fails when app is lauched from Terminal

2016-09-27 Thread じょいすじょん
Have you also tried NSWorkspace for this?

> On 2016 Sep 27, at 2:38, Markus Spoettl  wrote:
> 
> It is an OSX Cocoa GUI application. I have always started it from the command 
> line by executing the executable inside the bundle. While this always worked, 
> it no longer seems to.
> 
> That said, it didn't occur to me that there's a proper way, by using the 
> "open" command. Thanks for the tip, this works nicely for my purposes!
> 
> Regards
> Markus
> 
> On 26/09/16 19:18, Gary L. Wade wrote:
>> In what way did you start your app from the Terminal?  Is this
>> WindowServer-based or a command line app?  Not sure your purpose in starting
>> from the command line if WindowServer-based, but have you tried launching it
>> with the open command where the argument is the .app bundle vs possibly 
>> another
>> way like the actual executable?
>> --
>> Gary L. Wade
>> http://www.garywade.com/
>> 
>>> On Sep 26, 2016, at 2:44 AM, Markus Spoettl >> > wrote:
>>> 
>>> I'm using SecStaticCodeCheckValidity() to self check the signature of my own
>>> app when it is launched. This works fine and always has.
>>> 
>>> All of a sudden, the call to SecStaticCodeCheckValidity() fails if (and only
>>> if the application) is started from the Terminal. When I start the very same
>>> app from the Dock or from the Finder the check succeeds (iow. the call 
>>> returns
>>> noErr).
>>> 
>>> I don't know exactly when it started failing. I only know it definitely 
>>> worked
>>> before on previous versions of El Capitan but now it no longer does (v 
>>> 10.11.6).
>>> 
>>> Any ideas?
>>> 
>>> Regards
>>> Markus
>>> --
>>> __
>>> Markus Spoettl
>>> ___
>>> 
>>> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com
>>> )
>>> 
>>> Please do not post admin requests or moderator comments to the list.
>>> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
>>> 
>>> 
>>> Help/Unsubscribe/Update your Subscription:
>>> https://lists.apple.com/mailman/options/cocoa-dev/garywade%40desisoftsystems.com
>>> 
>>> This email sent to garyw...@desisoftsystems.com
>> 
> 
> 
> -- 
> __
> Markus Spoettl
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/dangerwillrobinsondanger%40gmail.com
> 
> This email sent to dangerwillrobinsondan...@gmail.com


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: SecStaticCodeCheckValidity fails when app is lauched from Terminal

2016-09-26 Thread Markus Spoettl
It is an OSX Cocoa GUI application. I have always started it from the command 
line by executing the executable inside the bundle. While this always worked, it 
no longer seems to.


That said, it didn't occur to me that there's a proper way, by using the "open" 
command. Thanks for the tip, this works nicely for my purposes!


Regards
Markus

On 26/09/16 19:18, Gary L. Wade wrote:

In what way did you start your app from the Terminal?  Is this
WindowServer-based or a command line app?  Not sure your purpose in starting
from the command line if WindowServer-based, but have you tried launching it
with the open command where the argument is the .app bundle vs possibly another
way like the actual executable?
--
Gary L. Wade
http://www.garywade.com/


On Sep 26, 2016, at 2:44 AM, Markus Spoettl > wrote:

I'm using SecStaticCodeCheckValidity() to self check the signature of my own
app when it is launched. This works fine and always has.

All of a sudden, the call to SecStaticCodeCheckValidity() fails if (and only
if the application) is started from the Terminal. When I start the very same
app from the Dock or from the Finder the check succeeds (iow. the call returns
noErr).

I don't know exactly when it started failing. I only know it definitely worked
before on previous versions of El Capitan but now it no longer does (v 10.11.6).

Any ideas?

Regards
Markus
--
__
Markus Spoettl
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com
)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com


Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/garywade%40desisoftsystems.com

This email sent to garyw...@desisoftsystems.com





--
__
Markus Spoettl
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: SecStaticCodeCheckValidity fails when app is lauched from Terminal

2016-09-26 Thread Gary L. Wade
In what way did you start your app from the Terminal?  Is this 
WindowServer-based or a command line app?  Not sure your purpose in starting 
from the command line if WindowServer-based, but have you tried launching it 
with the open command where the argument is the .app bundle vs possibly another 
way like the actual executable?
--
Gary L. Wade
http://www.garywade.com/ 
> On Sep 26, 2016, at 2:44 AM, Markus Spoettl  wrote:
> 
> I'm using SecStaticCodeCheckValidity() to self check the signature of my own 
> app when it is launched. This works fine and always has.
> 
> All of a sudden, the call to SecStaticCodeCheckValidity() fails if (and only 
> if the application) is started from the Terminal. When I start the very same 
> app from the Dock or from the Finder the check succeeds (iow. the call 
> returns noErr).
> 
> I don't know exactly when it started failing. I only know it definitely 
> worked before on previous versions of El Capitan but now it no longer does (v 
> 10.11.6).
> 
> Any ideas?
> 
> Regards
> Markus
> -- 
> __
> Markus Spoettl
> ___
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> https://lists.apple.com/mailman/options/cocoa-dev/garywade%40desisoftsystems.com
> 
> This email sent to garyw...@desisoftsystems.com

___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: SecStaticCodeCheckValidity fails when app is lauched from Terminal

2016-09-26 Thread Markus Spoettl

On 26/09/16 15:16, Steve Christensen wrote:

What is the error code when it fails?


OSStatus is -67054, which is errSecCSBadResource. Only happens when launched 
from the command line.


Markus

--
__
Markus Spoettl
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Re: SecStaticCodeCheckValidity fails when app is lauched from Terminal

2016-09-26 Thread Steve Christensen
What is the error code when it fails?


> On Sep 26, 2016, at 2:44 AM, Markus Spoettl  wrote:
> 
> I'm using SecStaticCodeCheckValidity() to self check the signature of my own 
> app when it is launched. This works fine and always has.
> 
> All of a sudden, the call to SecStaticCodeCheckValidity() fails if (and only 
> if the application) is started from the Terminal. When I start the very same 
> app from the Dock or from the Finder the check succeeds (iow. the call 
> returns noErr).
> 
> I don't know exactly when it started failing. I only know it definitely 
> worked before on previous versions of El Capitan but now it no longer does (v 
> 10.11.6).
> 
> Any ideas?
> 
> Regards
> Markus


___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

SecStaticCodeCheckValidity fails when app is lauched from Terminal

2016-09-26 Thread Markus Spoettl
I'm using SecStaticCodeCheckValidity() to self check the signature of my own app 
when it is launched. This works fine and always has.


All of a sudden, the call to SecStaticCodeCheckValidity() fails if (and only if 
the application) is started from the Terminal. When I start the very same app 
from the Dock or from the Finder the check succeeds (iow. the call returns noErr).


I don't know exactly when it started failing. I only know it definitely worked 
before on previous versions of El Capitan but now it no longer does (v 10.11.6).


Any ideas?

Regards
Markus
--
__
Markus Spoettl
___

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com