ZHYTOMYR, Ukraine — The North Korean spy, posing as a member of his country’s trade delegation in Belarus, thought he was photographing a secret scientific report on missile technology as he snapped away with a small camera in a dingy garage in the Ukrainian city of Dnipro, the home of Ukraine’s Soviet-era rocket industry.

But the report he took pictures of was a fake, part of a sting operation mounted by Ukraine’s security service to prevent the leak of missile secrets, and now the spy, 56-year-old Ri Tae-gil, is in prison convicted of espionage. He sleeps on the bottom bunk in a cell shared with eight Ukrainian inmates, four of them convicted murderers.

His July 2011 arrest in eastern Ukraine along with a fellow North Korean spy, which was first reported earlier this month by CNN, shows the extent to which Pyongyang has scoured the world for foreign technology to reinvigorate what had been a faltering program to develop long-range missiles.

Mr. Ri and his partner, Ryu Song-chol, 46, were arrested just a few days before North Korea’s then leader, Kim Jong-il, announced during a visit to Russia that Pyongyang was considering a moratorium on missile production and nuclear weapons testing. The moratorium never came about.