Posts

Post not yet marked as solved
5 Replies
4.5k Views
I have a MacBook Pro 2018 running Catalina with a USB-to-Ethernet Dongle. The MacBook is connected to power source and with an Ethernet cable to a router. Just in case, In "System preferences > Energy Saver" I have set "Wake for Wi-Fi network access" checkbox. There is a Linux machine with an ethernet connection to the same router -- they are in same LAN segment. My goal is to wake a sleeping MacBook with a Magic WakeOnLan packet, sent from a Linux machine. However none of the Linux apps I tried worked: neither wakeonlan perl script (that sends broadcast UDP messages), nor etherwake (that sends raw MAC frames). On various internet sources I've found controversial information: some complaints that when Mac is sleeping it goes to hybernation, meaning you can't WakeOnLan a sleeping Mac. I am using a regular router, not Apple AirPort (and don't have Apple TVs on my network). Is my understanding correct, that 1) There is no way to wake up a sleeping Mac by sending a magic WoL packet anymore (even though it used to be possible in older macOS versions) 2) If I get AirPort Extreme, and connect it to my router, I will be able to wake up Mac just by trying to access any of the network services I have enabled in Sharing on my MacBook?
Posted
by O.W.Grant.
Last updated
.
Post not yet marked as solved
1 Replies
930 Views
Hello I have created a signature of a chunk of text using the following OpenSSL CLI command: echo -n "sample text" | openssl dgst -sha1 -binary | openssl rsautl -sign -inkey "privatekey.pem" Basically what it does it calculating sha1 digest of text, and then signing this calculated digest as a binary blob with OpenSSL RSA signing using a private key in a PEM format. Now I would like to verify whether this "sample text" was signed by the owner of the privatekey.pem using a matching publickey.pem file, from within a macOS application. I can easily verify the signature by "decrypting" it using openssl dylib, something like this: int returnedDigestSize = RSA_public_decrypt((int)signatureLength, signatureBytes, destination, rsa_key, RSA_PKCS1_PADDING); (this will return me an original SHA1 digest, which I can then compare with the original string's SHA1 digest) However I wouldn't like to have any dependencies on openssl, and would like to move to MacOS security libraries I ended up attempting to use Security framework, since it is supported in earlier versions of macOS (I need all the way back to High Sierra). What I am doing is the following: NSData *pubKeyData = [kPublicRSAKey dataUsingEncoding:NSUTF8StringEncoding]; SecExternalFormat keyFormat = kSecFormatOpenSSL; SecExternalItemType keyType = kSecItemTypePublicKey; CFArrayRef cfImportedItems = NULL; OSStatus retval = 0; retval = SecItemImport((CFDataRef)pubKeyData, NULL, &keyFormat, &keyType, 0, NULL, NULL, &cfImportedItems); NSArray *importedItems = (__bridge NSArray*)cfImportedItems; 		 if(!retval && importedItems && importedItems.count == 1) { 		SecKeyRef pubKeyAppleFormat = (__bridge SecKeyRef)(importedItems[0]); 		CFErrorRef cfError = NULL; 								 		Boolean b = SecKeyIsAlgorithmSupported(pubKeyAppleFormat, kSecKeyOperationTypeDecrypt, kSecKeyAlgorithmRSAEncryptionPKCS1); 		NSLog(@"Algorithm supported: %d", b); 						 		CFDataRef cfDigestData = SecKeyCreateDecryptedData(pubKeyAppleFormat, kSecKeyAlgorithmRSAEncryptionPKCS1, (CFDataRef)signatureData, &cfError); 		if(!cfDigestData) { 				NSLog(@"SecKeyCreateDecryptedData error%@", (__bridge NSError*)cfError); 		} else { 				NSLog(@"%@", (__bridge NSData*)cfDigestData); 		} } This gives me an error: SecKeyCreateDecryptedData errorError Domain=NSOSStatusErrorDomain Code=-50 "RSAdecrypt wrong input (err -27)" (paramErr: error in user parameter list) UserInfo={numberOfErrorsDeep=0, NSDescription=RSAdecrypt wrong input (err -27)} Note that OpenSSL code above can decrypt this with RSA_PKCS1_PADDING argument. If instead of kSecKeyAlgorithmRSAEncryptionPKCS1 I put kSecKeyAlgorithmRSAEncryptionRaw, I do get some bytes and no errors, however they are incorrect, as OpenSSL CLI uses PKCS1. Is there a way to get a matching to OpenSSL signature verification via macOS APIs?
Posted
by O.W.Grant.
Last updated
.
Post not yet marked as solved
0 Replies
330 Views
Hello If we set an NSImage.template = YES, it becomes grayscale, automatically follows dark mode, and so on. Is there a way to save it as a png as a template, the way it would be rendered by a system?
Posted
by O.W.Grant.
Last updated
.
Post not yet marked as solved
1 Replies
445 Views
Hello What is the right way to get the AppIcon image representation of the desired size? Say, I have filled out the AppIcon with all images from 16x16 up to 1024x1024. Whenever I do NSImage(named: "AppIcon") I get the largest possible image (judging by the image.size). Is there a way to get a, for example, 32x32 image? Or do I have to draw the image manually as shown here https://stackoverflow.com/questions/11949250/how-to-resize-nsimage/17396521 ? Thanks
Posted
by O.W.Grant.
Last updated
.
Post not yet marked as solved
5 Replies
1.7k Views
HelloFor my word processing app I need to be able to retrieve a specific paragraph of a book that is opened in Books.app on Mac. Using Accessibility APIs I am able to descend the tree of views down to AXStaticText, however whenever I try to read AXValue I always get nil. Also, I cannot read that text using Apple Script (of course, Script Editor is enabled as an Accessibility app in Security & Privacy)Xcode's Accessibility Inspector, however, returns correct text of the paragraph in Books I am pointing it to.I was wondering if it could be due to some DRM protection? But if so, I don't understand, how come Accessibility Inspector is able to read the text?Thanks!
Posted
by O.W.Grant.
Last updated
.
Post marked as solved
2 Replies
562 Views
I am trying to launch an app, and open a specific document with it.For example, to launch Sublime Text, I can do it using the following call[[NSWorkspace sharedWorkspace] launchAppWithBundleIdentifier:@"com.sublimetext.3" options:(0) additionalEventParamDescriptor:nillaunchIdentifier:nil];How do I pass a url of a document to the app, to make Sublime Text open this document after launch? I believe this can be done using additionalEventParamDescriptor, but I can't find an example anywhere on how to build a correct NSAppleEventDescriptor for an "open document" event.Thanks!
Posted
by O.W.Grant.
Last updated
.
Post not yet marked as solved
1 Replies
484 Views
HelloI would like to attach a custom action on touch id button press. Currently, when pressed for a second, it tries to switch user. I would like it to make it go to the sleep. Touch strip is very inconvenient in that regard - I have a "Sleep" touchstrip button, which I occasionally touch by mistake and the laptop goes to sleep all of a sudden. I prefer a physical button for that.Is there a way to detect the touch id button being physically pushed (by making some HID events filter, perhaps)?
Posted
by O.W.Grant.
Last updated
.
Post not yet marked as solved
3 Replies
737 Views
Hello,There is an Button in one of Xcode's panels, as shown on the pictures here: https://imgur.com/a/SHd0BQ4 (the button is titled "In Project"). Unlike a regular NSButton, it has an NSColor.controlAccentColor along with colorWithSystemEffect colors on hover and when clicked (so it uses "accent color" selected in the System Preferences, instead of default "Gray" tint).Is there a way to get a similar button by styling existing NSButton, or subclassing and drawing everything, including title text, image, rounded corners, and background, is the only way to get a similar result?Thank you!
Posted
by O.W.Grant.
Last updated
.
Post not yet marked as solved
7 Replies
2.3k Views
Hello!I am looking for a way for a process to publish some string system wide (or, preferably, user-session wide, if possible), so another process or processes could search for this string upon launch. What is important is that this string should disappear once the publishing process dies or gets killed.I know there exist POSIX named semaphores (sem_open() ) and POSIX named shared memory segments (shmopen()), but both allow specifying a maximum of 31 bytes in their names. I need at least 255.I was considering something like NSUserDefaults (or just regular files), but it is impossible to reliably clean them up upon process termination, which is essential.Are there any other options available on macOS I could try?It would be ideal, if this approach, apart from publishing a string that is accessible to other interested processes, also allowed sending messages between these processes, but this is not critical.My main goal is to make a process and some of its configuration parameters discoverable by other instances of this process upon launch.Thank you for answers!
Posted
by O.W.Grant.
Last updated
.